Package org.jruby
Class RubyEncoding
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyEncoding
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IRubyObject>,Constantizable,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA cached decoder object to decode bytes as raw binary (ISO-8859-1 or ASCII-8BIT) content.private static classA cached decoder for UTF-8 bytes.Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe maximum number of characters we can encode/decode in our cached buffersprivate final Objectprivate org.jcodings.Encodingstatic final ByteListstatic final ByteListstatic final ByteListprivate final booleanstatic final Charsetstatic final ByteListprivate final ByteListprivate static final ThreadLocal<SoftReference<RubyEncoding.RawCoder>>Thread-local RawCoder wrapped in a SoftReference to avoid possible ClassLoader leak.static final Charsetstatic final Charsetprivate static final ThreadLocal<SoftReference<RubyEncoding.UTF8Coder>>Thread-local UTF8Coder wrapped in a SoftReference to avoid possible ClassLoader leak.Fields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATORFields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, UNTRUST_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStampFields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateRubyEncoding(Ruby runtime, byte[] name, int p, int end, boolean isDummy) privateRubyEncoding(Ruby runtime, byte[] name, org.jcodings.Encoding encoding, boolean isDummy) privateRubyEncoding(Ruby runtime, ByteList name, org.jcodings.Encoding encoding, boolean isDummy) -
Method Summary
Modifier and TypeMethodDescription_dump(ThreadContext context, IRubyObject arg) static IRubyObject_load(ThreadContext context, IRubyObject recv, IRubyObject str) static IRubyObjectaliases(ThreadContext context, IRubyObject recv) static org.jcodings.EncodingareCompatible(org.jcodings.Encoding enc1, int cr1, org.jcodings.Encoding enc2, int cr2) static org.jcodings.EncodingareCompatible(IRubyObject obj1, IRubyObject obj2) asciiCompatible_p(ThreadContext context) static IRubyObjectcompatible_p(ThreadContext context, IRubyObject self, IRubyObject first, IRubyObject second) constant()static RubyClasscreateEncodingClass(Ruby runtime) static Stringstatic Stringstatic StringdecodeISO(byte[] bytes, int start, int length) Deprecated.static StringDeprecated.static StringdecodeRaw(byte[] bytes, int start, int length) Decode the range of bytes specified as "raw" binary content, as in ISO-8859-1 or ASCII-8BIT encodings.static StringDecode the specified bytelist as "raw" binary content.private static char[]decodeRawLoop(byte[] s, int start, int length) static StringdecodeUTF8(byte[] bytes) static StringdecodeUTF8(byte[] bytes, int start, int length) Decode the range of bytes specified as UTF-8 content.(package private) static ByteListdoEncode(CharSequence cs, Charset charset, org.jcodings.Encoding enc) (package private) static ByteList(package private) static ByteList(package private) static ByteListdoEncodeUTF16(String str) (package private) static ByteListdoEncodeUTF8(CharSequence str) (package private) static ByteListdoEncodeUTF8(String str) dummy_p(ThreadContext context) static byte[]encode(CharSequence cs, Charset charset) static byte[]static byte[]encodeISO(char[] str) static byte[]encodeISO(CharSequence str) private static byte[]encodeISOLoop(char[] s) private static byte[]static byte[]encodeUTF16(CharSequence str) static byte[]encodeUTF16(String str) static byte[]encodeUTF8(CharSequence str) static byte[]encodeUTF8(String str) private static org.jcodings.Encodingstatic IRubyObjectfind(ThreadContext context, IRubyObject recv, IRubyObject str) private static ByteListgetByteList(ByteBuffer buffer, org.jcodings.Encoding enc, boolean shared) private static byte[]getBytes(ByteBuffer buffer) static IRubyObjectgetDefaultExternal(ThreadContext context, IRubyObject recv) static IRubyObjectDeprecated.static IRubyObjectgetDefaultInternal(ThreadContext context, IRubyObject recv) final org.jcodings.Encodingprivate static RubyEncoding.RawCoderprivate static RubyEncoding.UTF8Coderinspect(ThreadContext context) static IRubyObjectlist(ThreadContext context, IRubyObject recv) static IRubyObjectlocale_charmap(ThreadContext context, IRubyObject recv) static IRubyObjectname_list(ThreadContext context, IRubyObject recv) names(ThreadContext context) static RubyEncodingnewEncoding(Ruby runtime, byte[] name, int p, int end, boolean isDummy) replicate(ThreadContext context, IRubyObject arg) static IRubyObjectsetDefaultExternal(ThreadContext context, IRubyObject recv, IRubyObject encoding) static IRubyObjectsetDefaultInternal(ThreadContext context, IRubyObject recv, IRubyObject encoding) to_s(ThreadContext context) private static CharBuffertoCharBuffer(CharSequence str) Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, dig1, dig2, eqlInternal, equalInternal, equals, getNativeClassIndex, hashCode, inspect, op_eqq, puts, specificEval, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, defaultToJava, display, dup, ensureInstanceVariablesSettable, eql, eql_p, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, infectBy, infectBy, initialize, initialize_copy, initialize19, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method, method_missing, method_missing19, method19, methods, methods, methods19, methodsImpl, nil_p, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal, op_equal_19, op_match, op_match19, op_not, op_not_equal, op_not_match, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, rbClone, rbInspect, recacheBuiltinMethods, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method_added, singleton_method_added19, singleton_method_removed, singleton_method_removed19, singleton_method_undefined, singleton_method_undefined19, singleton_methods, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, toJava, trust, type, type_deprecated, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
-
Field Details
-
UTF8
-
UTF16
-
ISO
-
LOCALE
-
EXTERNAL
-
FILESYSTEM
-
INTERNAL
-
encoding
private org.jcodings.Encoding encoding -
name
-
isDummy
private final boolean isDummy -
constant
-
CHAR_THRESHOLD
private static final int CHAR_THRESHOLDThe maximum number of characters we can encode/decode in our cached buffers- See Also:
-
UTF8_CODER
Thread-local UTF8Coder wrapped in a SoftReference to avoid possible ClassLoader leak. See JRUBY-6522 -
RAW_CODER
Thread-local RawCoder wrapped in a SoftReference to avoid possible ClassLoader leak. See JRUBY-6522
-
-
Constructor Details
-
RubyEncoding
-
RubyEncoding
-
RubyEncoding
-
-
Method Details
-
createEncodingClass
-
constant
- Specified by:
constantin interfaceConstantizable- See Also:
-
newEncoding
-
getEncoding
public final org.jcodings.Encoding getEncoding() -
extractEncodingFromObject
-
areCompatible
-
areCompatible
public static org.jcodings.Encoding areCompatible(org.jcodings.Encoding enc1, int cr1, org.jcodings.Encoding enc2, int cr2) -
encodeUTF8
-
encodeUTF8
-
encodeISO
-
encodeISO
public static byte[] encodeISO(char[] str) -
encodeISOLoop
private static byte[] encodeISOLoop(char[] s) -
encodeISOLoop
-
doEncodeUTF8
-
doEncodeUTF8
-
toCharBuffer
-
getBytes
-
getByteList
-
encodeUTF16
-
encodeUTF16
-
doEncodeUTF16
-
doEncodeUTF16
-
encode
-
doEncode
-
doEncode
-
encode
-
decodeUTF8
Decode the range of bytes specified as UTF-8 content. This will attempt to use a zero-allocation decoder if the content length is shorter thanCHAR_THRESHOLDbytes, and otherwise will used cached decoders to avoid reallocating Charset-related objects.- Parameters:
bytes- the byte arraystart- start of contentlength- length of content- Returns:
- a decoded String based on UTF-8 bytes
-
decodeRaw
Decode the range of bytes specified as "raw" binary content, as in ISO-8859-1 or ASCII-8BIT encodings. This will attempt to use a zero-allocation decoder if the content length is shorter thanCHAR_THRESHOLDbytes, and otherwise will used cached decoders to avoid reallocating Charset-related objects.- Parameters:
bytes- the byte arraystart- start of contentlength- length of content- Returns:
- a decoded String based on raw bytes
-
decodeRaw
Decode the specified bytelist as "raw" binary content. This is the same as callingdecodeRaw(byte[], int, int)with the contents of byteList.- Parameters:
byteList-- Returns:
- a decoded string based on raw bytes
-
decodeRawLoop
private static char[] decodeRawLoop(byte[] s, int start, int length) -
decodeUTF8
-
decode
-
decode
-
getUTF8Coder
-
getRawCoder
-
list
-
locale_charmap
-
name_list
-
aliases
-
find
-
replicate
-
_dump
-
_load
-
asciiCompatible_p
-
to_s
-
inspect
-
names
-
dummy_p
-
compatible_p
public static IRubyObject compatible_p(ThreadContext context, IRubyObject self, IRubyObject first, IRubyObject second) -
getDefaultExternal
-
setDefaultExternal
public static IRubyObject setDefaultExternal(ThreadContext context, IRubyObject recv, IRubyObject encoding) -
getDefaultInternal
-
getDefaultInternal
Deprecated. -
setDefaultInternal
public static IRubyObject setDefaultInternal(ThreadContext context, IRubyObject recv, IRubyObject encoding) -
decodeISO
Deprecated. -
decodeISO
Deprecated.
-
decodeRaw(byte[], int, int)