private void initEmitter(ThreadContext context, IRubyObject _encoding) { if (emitter != null) throw context.runtime.newRuntimeError("already initialized emitter"); Encoding encoding = PsychLibrary.YAMLEncoding.values()[(int)_encoding.convertToInteger().getLongValue()].encoding; Charset charset = context.runtime.getEncodingService().charsetForEncoding(encoding); emitter = new Emitter(new OutputStreamWriter(new IOOutputStream(io, encoding), charset), options); }
private void initEmitter(ThreadContext context, IRubyObject _encoding) { if (emitter != null) throw context.runtime.newRuntimeError("already initialized emitter"); Encoding encoding = PsychLibrary.YAMLEncoding.values()[(int)_encoding.convertToInteger().getLongValue()].encoding; Charset charset = context.runtime.getEncodingService().charsetForEncoding(encoding); emitter = new Emitter(new OutputStreamWriter(new IOOutputStream(io, encoding), charset), options); }
Reader reader = new InputStreamReader(in, runtime.getEncodingService().charsetForEncoding(pattern.getEncoding())); lexer.yyreset(reader);
Reader reader = new InputStreamReader(in, runtime.getEncodingService().charsetForEncoding(pattern.getEncoding())); lexer.yyreset(reader);
Reader reader = new InputStreamReader(in, context.runtime.getEncodingService().charsetForEncoding(pattern.getEncoding())); lexer.yyreset(reader);
Reader reader = new InputStreamReader(in, context.runtime.getEncodingService().charsetForEncoding(pattern.getEncoding())); lexer.yyreset(reader);
toAppendTo.append(formatted.getBytes(runtime.getEncodingService().charsetForEncoding(toAppendTo.getEncoding())));
toAppendTo.append(formatted.getBytes(runtime.getEncodingService().charsetForEncoding(toAppendTo.getEncoding())));
Charset charset = runtime.getEncodingService().charsetForEncoding(encoding);
Charset charset = runtime.getEncodingService().charsetForEncoding(encoding);
if (srcEncoding != null) encodingService.charsetForEncoding(srcEncoding); if (destEncoding != null) encodingService.charsetForEncoding(destEncoding);
if (srcEncoding != null) encodingService.charsetForEncoding(srcEncoding); if (destEncoding != null) encodingService.charsetForEncoding(destEncoding);
/** * Decode a given ByteList to a Java string. * * @param runtime the current runtime * @param value the bytelist * @return a Java String representation of the ByteList */ public static String decodeByteList(Ruby runtime, ByteList value) { byte[] unsafeBytes = value.getUnsafeBytes(); int begin = value.getBegin(); int length = value.length(); Encoding encoding = value.getEncoding(); if (encoding == UTF8Encoding.INSTANCE) { return RubyEncoding.decodeUTF8(unsafeBytes, begin, length); } Charset charset = runtime.getEncodingService().charsetForEncoding(encoding); if (charset == null) { // No JDK Charset available for this encoding; convert to UTF-16 ourselves. Encoding utf16 = EncodingUtils.getUTF16ForPlatform(); return EncodingUtils.strConvEnc(runtime.getCurrentContext(), value, value.getEncoding(), utf16).toString(); } return RubyEncoding.decode(unsafeBytes, begin, length, charset); }
toAppendTo.append(output.getBytes(context.runtime.getEncodingService().charsetForEncoding(toAppendTo.getEncoding())));
toAppendTo.append(output.getBytes(context.runtime.getEncodingService().charsetForEncoding(toAppendTo.getEncoding())));
/** * Decode a given ByteList to a Java string. * * @param runtime the current runtime * @param value the bytelist * @return a Java String representation of the ByteList */ public static String decodeByteList(Ruby runtime, ByteList value) { byte[] unsafeBytes = value.getUnsafeBytes(); int begin = value.getBegin(); int length = value.length(); Encoding encoding = value.getEncoding(); if (encoding == UTF8Encoding.INSTANCE) { return RubyEncoding.decodeUTF8(unsafeBytes, begin, length); } Charset charset = runtime.getEncodingService().charsetForEncoding(encoding); if (charset == null) { // No JDK Charset available for this encoding; convert to UTF-16 ourselves. Encoding utf16 = EncodingUtils.getUTF16ForPlatform(); return EncodingUtils.strConvEnc(runtime.getCurrentContext(), value, value.getEncoding(), utf16).toString(); } return RubyEncoding.decode(unsafeBytes, begin, length, charset); }