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 classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ByteListstatic final ByteListstatic final ByteListstatic final ByteListstatic final Charsetstatic final ByteListstatic final Charsetstatic final CharsetFields 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, 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 -
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 org.jcodings.EncodingcheckEncoding(ThreadContext context, org.jcodings.Encoding encoding, CodeRangeable other) Check whether the given encoding and the encoding from the givenCodeRangeableare compatible.static IRubyObjectcompatible_p(ThreadContext context, IRubyObject self, IRubyObject first, IRubyObject second) constant()static RubyClasscreateEncodingClass(ThreadContext context, RubyClass Object) 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.static StringdecodeUTF8(byte[] bytes) static StringdecodeUTF8(byte[] bytes, int start, int length) Decode the range of bytes specified as UTF-8 content.dummy_p(ThreadContext context) static byte[]encode(CharSequence cs, Charset charset) static byte[]static byte[]encodeISO(char[] str) static byte[]encodeISO(CharSequence str) static byte[]encodeUTF16(CharSequence str) static byte[]encodeUTF16(String str) static byte[]encodeUTF8(CharSequence str) static byte[]encodeUTF8(String str) static IRubyObjectfind(ThreadContext context, IRubyObject recv, IRubyObject str) static IRubyObjectgetDefaultExternal(ThreadContext context, IRubyObject recv) static IRubyObjectDeprecated.static IRubyObjectgetDefaultInternal(ThreadContext context, IRubyObject recv) final org.jcodings.Encodinginspect(ThreadContext context) Returns a string containing a human-readable representation of obj.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) Deprecated.static IRubyObjectsetDefaultExternal(ThreadContext context, IRubyObject recv, IRubyObject encoding) static IRubyObjectsetDefaultInternal(ThreadContext context, IRubyObject recv, IRubyObject encoding) to_s(ThreadContext context) Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, dig, dig1, dig2, eqlInternal, equalInternal, equals, finishObjectClass, getNativeClassIndex, hashCode, inspect, op_eqq, puts, specificEval, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dup, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, initialize_copy, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal, op_match, op_not, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, toJava, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnderMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Field Details
-
UTF8
-
UTF16
-
ISO
-
LOCALE
-
EXTERNAL
-
FILESYSTEM
-
INTERNAL
-
BINARY_ASCII_NAME
-
-
Method Details
-
createEncodingClass
-
constant
- Specified by:
constantin interfaceConstantizable- See Also:
-
newEncoding
-
getEncoding
public final org.jcodings.Encoding getEncoding() -
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) -
encodeUTF16
-
encodeUTF16
-
encode
-
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
-
decodeUTF8
-
decode
-
decode
-
checkEncoding
public static org.jcodings.Encoding checkEncoding(ThreadContext context, org.jcodings.Encoding encoding, CodeRangeable other) Check whether the given encoding and the encoding from the givenCodeRangeableare compatible. This version differs fromRubyString.checkEncoding(CodeRangeable)in that the contents of the first encoding's string are not taken into consideration (e.g. blank first string does not skip compatibility check with second string's encoding). See rb_enc_check in CRuby and use from stringio that passes encoding instead of string for the first argument. See https://github.com/ruby/stringio/pull/116 for some discussion MRI: rb_enc_check with encoding for first parameter- Parameters:
context- the current thread contextencoding- the first encodingother- theCodeRangeablefrom which to get bytes and the second encoding- Returns:
- a negotiated encoding, if compatible; null otherwise
-
list
-
locale_charmap
-
name_list
-
aliases
-
find
-
replicate
Deprecated. -
_dump
-
_load
-
asciiCompatible_p
-
to_s
- Overrides:
to_sin classRubyBasicObject
-
inspect
Description copied from class:RubyBasicObjectReturns a string containing a human-readable representation of obj. If not overridden, uses theto_smethod to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"- Specified by:
inspectin interfaceIRubyObject- Overrides:
inspectin classRubyBasicObject
-
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)