Package org.jruby.util.io
Class EncodingUtils
java.lang.Object
org.jruby.util.io.EncodingUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
Fallback function to provide replacements for characters that fail to transcode.static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final EncodingUtils.ResizeFunction
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.jcodings.Encoding
ascii8bitEncoding
(Ruby runtime) static Charset
charsetForEncoding
(org.jcodings.Encoding enc) Get an appropriate Java Charset for the given Encoding.static int
decorateConvpath
(ThreadContext context, IRubyObject convpath, int ecflags) static boolean
DECORATOR_P
(byte[] sname, byte[] dname) static org.jcodings.Encoding
defaultExternalEncoding
(Ruby runtime) static org.jcodings.Encoding
defineDummyEncoding
(ThreadContext context, byte[] name) static ByteList
econvAppend
(ThreadContext context, org.jcodings.transcode.EConv ec, byte[] bytes, int start, int length, ByteList dst, int flags) static ByteList
econvAppend
(ThreadContext context, org.jcodings.transcode.EConv ec, ByteList sByteList, ByteList dst, int flags) static void
econvArgs
(ThreadContext context, IRubyObject[] args, byte[][] encNames, org.jcodings.Encoding[] encs, int[] ecflags_p, IRubyObject[] ecopts_p) static org.jcodings.Encoding
econvAsciicompatEncoding
(org.jcodings.Encoding enc) static ByteList
econvByteConvert
(ThreadContext context, org.jcodings.transcode.EConv ec, byte[] bytes, int start, int length, int flags) static void
econvCheckError
(ThreadContext context, org.jcodings.transcode.EConv ec) static String
econvDescription
(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags, String message) static org.jcodings.transcode.EConv
econvInitByConvpath
(ThreadContext context, IRubyObject convpathArg, byte[][] encNames, org.jcodings.Encoding[] encs) static RaiseException
econvOpenExc
(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags) static org.jcodings.transcode.EConv
econvOpenOpts
(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags, IRubyObject opthash) static int
econvOpts
(ThreadContext context, IRubyObject opt, int ecflags) static int
econvPrepareOptions
(ThreadContext context, IRubyObject opthash, IRubyObject[] opts, int ecflags) static int
econvPrepareOpts
(ThreadContext context, IRubyObject opthash, IRubyObject[] opts) static ByteList
econvStrConvert
(ThreadContext context, org.jcodings.transcode.EConv ec, ByteList src, int flags) static ByteList
econvSubstrAppend
(ThreadContext context, org.jcodings.transcode.EConv ec, ByteList src, ByteList dst, int flags) static org.jcodings.Encoding
encArg
(ThreadContext context, IRubyObject encval, byte[][] name_p, org.jcodings.Encoding[] enc_p) static int
encAscget
(byte[] pBytes, int p, int e, int[] len, org.jcodings.Encoding enc) static boolean
encAsciicompat
(org.jcodings.Encoding enc) static IRubyObject
encAssociateIndex
(IRubyObject obj, org.jcodings.Encoding encidx) static void
encCheckDuplication
(ThreadContext context, byte[] name) static int
encCodelen
(ThreadContext context, int c, org.jcodings.Encoding enc) static int
encCodepointLength
(byte[] pBytes, int p, int e, int[] len_p, org.jcodings.Encoding enc) static int
encCodepointLength
(Ruby runtime, byte[] pBytes, int p, int e, int[] len_p, org.jcodings.Encoding enc) Deprecated.static int
encCodepointLength
(ThreadContext context, byte[] pBytes, int p, int e, int[] len_p, org.jcodings.Encoding enc) static int
encCrStrBufCat
(Ruby runtime, CodeRangeable str, byte[] ptrBytes, int ptr, int len, org.jcodings.Encoding ptrEnc, int ptr_cr) static int
encCrStrBufCat
(Ruby runtime, CodeRangeable str, ByteList ptr, org.jcodings.Encoding ptrEnc, int ptr_cr) static boolean
encDummy
(org.jcodings.Encoding enc) static org.jcodings.Encoding
encGet
(ThreadContext context, IRubyObject obj) static int
encMbcput
(int c, byte[] buf, int p, org.jcodings.Encoding enc) static int
encMbcput
(ThreadContext context, int c, byte[] buf, int p, org.jcodings.Encoding enc) static int
encMbminlen
(org.jcodings.Encoding encoding) static RubyString
encodedDup
(ThreadContext context, RubyString str, org.jcodings.Encoding encindex, RubyString newstr) static IRubyObject
encodedDup
(ThreadContext context, IRubyObject newstr, IRubyObject str, org.jcodings.Encoding encindex) Deprecated.static boolean
encodingEqual
(byte[] enc1, byte[] enc2) encodingNames
(byte[] name, int p, int end) static boolean
encRegistered
(byte[] name) static org.jcodings.Encoding
encReplicate
(ThreadContext context, byte[] name, org.jcodings.Encoding encoding) static boolean
encSetDefaultEncoding
(ThreadContext context, org.jcodings.Encoding[] def_p, IRubyObject encoding, String name) static void
encStrBufCat
(Ruby runtime, RubyString str, byte[] ptrBytes) static void
encStrBufCat
(Ruby runtime, RubyString str, byte[] ptrBytes, int ptr, int len, org.jcodings.Encoding enc) static void
encStrBufCat
(Ruby runtime, RubyString str, byte[] ptrBytes, org.jcodings.Encoding enc) static void
encStrBufCat
(Ruby runtime, RubyString str, CharSequence cseq) static void
encStrBufCat
(Ruby runtime, RubyString str, ByteList ptr) static void
encStrBufCat
(Ruby runtime, RubyString str, ByteList ptr, org.jcodings.Encoding enc) static RubyString
encUintChr
(ThreadContext context, int code, org.jcodings.Encoding enc) static void
extractBinmode
(Ruby runtime, IRubyObject optionsArg, int[] fmode_p) Deprecated.static void
extractBinmode
(ThreadContext context, IRubyObject optionsArg, int[] fmode_p) static void
extractModeEncoding
(ThreadContext context, IOEncodable ioEncodable, Object vmodeAndVperm_p, IRubyObject options, int[] oflags_p, int[] fmode_p) Deprecated.static void
extractModeEncoding
(ThreadContext context, IOEncodable ioEncodable, API.ModeAndPermission vmodeAndVperm_p, IRubyObject options, int[] oflags_p, int[] fmode_p) static org.jcodings.Encoding
getActualEncoding
(org.jcodings.Encoding enc, byte[] bytes, int p, int end) static org.jcodings.Encoding
getActualEncoding
(org.jcodings.Encoding enc, ByteList byteList) static org.jcodings.Encoding
getEncoding
(ByteList str) static org.jcodings.Encoding
static RubyString
ioEncStr
(Ruby runtime, RubyString str, OpenFile fptr) static IRubyObject
ioEncStr
(Ruby runtime, IRubyObject str, OpenFile fptr) static void
ioExtIntToEncs
(ThreadContext context, IOEncodable encodable, org.jcodings.Encoding external, org.jcodings.Encoding internal, int fmode) static boolean
ioExtractEncodingOption
(ThreadContext context, IOEncodable ioEncodable, IRubyObject options, int[] fmode_p) static org.jcodings.Encoding
ioSetEncodingByBOM
(ThreadContext context, RubyIO io) static org.jcodings.Encoding
ioStripBOM
(RubyIO io) Deprecated.static org.jcodings.Encoding
ioStripBOM
(ThreadContext context, RubyIO io) static boolean
isPrint
(int c) static RaiseException
makeEconvException
(Ruby runtime, org.jcodings.transcode.EConv ec) Deprecated.static RaiseException
makeEconvException
(ThreadContext context, org.jcodings.transcode.EConv ec) static final int
MODE_BTMODE
(int fmode, int a, int b, int c) static RubyString
newExternalStringWithEncoding
(Ruby runtime, String string, org.jcodings.Encoding encoding) static RubyString
newExternalStringWithEncoding
(Ruby runtime, ByteList bytelist, org.jcodings.Encoding encoding) protected static boolean
noDecorators
(int ecflags) static IRubyObject
objEncoding
(ThreadContext context, IRubyObject obj) static IRubyObject[]
openArgsToArgs
(Ruby runtime, IRubyObject firstElement, RubyHash options) Deprecated.static IRubyObject[]
openArgsToArgs
(ThreadContext context, IRubyObject firstElement, RubyHash options) Deprecated.static void
parseModeEncoding
(ThreadContext context, IOEncodable ioEncodable, String option, int[] fmode_p) static org.jcodings.Encoding
rbAscii8bitAppendableEncodingIndex
(ThreadContext context, org.jcodings.Encoding enc, int code) static ByteList
rbByteEncode
(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, int cr, org.jcodings.Encoding to, int ecflags, IRubyObject ecopt) A version of rbStrEncode that works directly with bytes.static void
rbEncSetDefaultExternal
(ThreadContext context, IRubyObject encoding) static void
rbEncSetDefaultInternal
(ThreadContext context, IRubyObject encoding) static void
rbStrBufCat
(Ruby runtime, RubyString str, ByteList ptr) static void
rbStrBufCat
(Ruby runtime, ByteListHolder str, byte[] ptrBytes, int ptr, int len) static void
rbStrBufCat
(Ruby runtime, ByteList str, byte[] ptrBytes, int ptr, int len) static int
rbStrBufCatEscapedChar
(RubyString result, long c, boolean unicode_p) static IRubyObject
rbStrEncode
(ThreadContext context, IRubyObject str, IRubyObject to, int ecflags, IRubyObject ecopt) static RubyString
rbStrEscape
(Ruby runtime, RubyString str) Deprecated.static org.jcodings.Encoding
rbToEncoding
(ThreadContext context, IRubyObject enc) static int
SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2
(org.jcodings.Encoding enc2, int ecflags) static RubyString
setStrBuf
(Ruby runtime, IRubyObject obj, int len) static org.jcodings.Encoding
static void
strBufCat
(Ruby runtime, RubyString str, ByteList ptr) static void
strBufCat
(Ruby runtime, ByteListHolder str, byte[] ptrBytes, int ptr, int len) static void
static IRubyObject
strCompatAndValid
(ThreadContext context, IRubyObject _str, org.jcodings.Encoding enc) static RubyString
strConvEnc
(ThreadContext context, RubyString value, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding) static ByteList
strConvEnc
(ThreadContext context, ByteList value, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding) static RubyString
strConvEncOpts
(ThreadContext context, RubyString str, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding, int ecflags, IRubyObject ecopts) This will try and transcode the supplied ByteList to the supplied toEncoding.static ByteList
strConvEncOpts
(ThreadContext context, ByteList str, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding, int ecflags, IRubyObject ecopts) static IRubyObject
strEncode
(ThreadContext context, RubyString str) static IRubyObject
strEncode
(ThreadContext context, RubyString str, IRubyObject toEncoding) static IRubyObject
strEncode
(ThreadContext context, RubyString str, IRubyObject toEncoding, IRubyObject forcedEncoding) static IRubyObject
strEncode
(ThreadContext context, RubyString str, IRubyObject toEncoding, IRubyObject forcedEncoding, IRubyObject opts) static IRubyObject
strEncode
(ThreadContext context, IRubyObject str, IRubyObject... args) Deprecated.static RubyString
strEncodeAssociate
(RubyString str, org.jcodings.Encoding encidx) static IRubyObject
strEncodeAssociate
(ThreadContext context, IRubyObject str, org.jcodings.Encoding encidx) Deprecated.static IRubyObject
strTranscode
(ThreadContext context, RubyString str, EncodingUtils.TranscodeResult result) static IRubyObject
strTranscode
(ThreadContext context, IRubyObject[] args, RubyString str, EncodingUtils.TranscodeResult result) Deprecated.static org.jcodings.Encoding
strTranscode
(ThreadContext context, IRubyObject[] args, IRubyObject[] self_p) Deprecated.static IRubyObject
strTranscode
(ThreadContext context, IRubyObject toEncoding, RubyString str, EncodingUtils.TranscodeResult result) static IRubyObject
strTranscode
(ThreadContext context, IRubyObject toEncoding, IRubyObject forcedEncoding, RubyString str, EncodingUtils.TranscodeResult result) static IRubyObject
strTranscode
(ThreadContext context, IRubyObject toEncoding, IRubyObject forcedEncoding, IRubyObject opts, RubyString str, EncodingUtils.TranscodeResult result) static org.jcodings.Encoding
strTranscode0
(ThreadContext context, int argc, IRubyObject[] args, IRubyObject[] self_p, int ecflags, IRubyObject ecopts) Deprecated.static org.jcodings.Encoding
strTranscodeEncArgs
(ThreadContext context, IRubyObject str, IRubyObject arg1, IRubyObject arg2, byte[][] sname_p, org.jcodings.Encoding[] senc_p, byte[][] dname_p, org.jcodings.Encoding[] denc_p) static org.jcodings.Encoding
toEncoding
(ThreadContext context, IRubyObject enc) static org.jcodings.Encoding
toEncodingIndex
(ThreadContext context, IRubyObject enc) static <Data> boolean
transcodeLoop
(org.jcodings.transcode.EConv ec, EncodingUtils.TranscodeFallback<Data> fallbackFunc, ThreadContext context, Data fallbackData, byte[] inBytes, org.jcodings.Ptr inPos, byte[] outBytes, org.jcodings.Ptr outPos, int inStop, int outStop, ByteList destination, EncodingUtils.ResizeFunction resizeFunction) Perform the inner transcoding loop.static void
transcodeLoop
(ThreadContext context, byte[] inBytes, org.jcodings.Ptr inPos, byte[] outBytes, org.jcodings.Ptr outPos, int inStop, int _outStop, ByteList destination, EncodingUtils.ResizeFunction resizeFunction, byte[] sname, byte[] dname, int ecflags, IRubyObject ecopts) Perform the inner transcoding loop.static ByteList
transcodeString
(String string, org.jcodings.Encoding toEncoding, int ecflags) A version of transcodeLoop for working without any Ruby runtime available.static void
validateEncodingBinmode
(ThreadContext context, int[] fmode_p, int ecflags, IOEncodable ioEncodable) static IRubyObject
Deprecated.static void
vmode
(Object vmodeVperm, IRubyObject vmode) Deprecated.static IRubyObject
vmode
(API.ModeAndPermission vmodeVperm) static void
vmode
(API.ModeAndPermission vmodeVperm, IRubyObject vmode) static Object
vmodeVperm
(IRubyObject vmode, IRubyObject vperm) Deprecated.static IRubyObject
Deprecated.static void
vperm
(Object vmodeVperm, IRubyObject vperm) Deprecated.static IRubyObject
vperm
(API.ModeAndPermission vmodeVperm) static void
vperm
(API.ModeAndPermission vmodeVperm, IRubyObject vperm)
-
Field Details
-
ECONV_DEFAULT_NEWLINE_DECORATOR
public static final int ECONV_DEFAULT_NEWLINE_DECORATOR -
DEFAULT_TEXTMODE
public static final int DEFAULT_TEXTMODE -
TEXTMODE_NEWLINE_DECORATOR_ON_WRITE
public static final int TEXTMODE_NEWLINE_DECORATOR_ON_WRITE -
strTranscodingResize
-
-
Constructor Details
-
EncodingUtils
public EncodingUtils()
-
-
Method Details
-
rbToEncoding
-
toEncoding
-
openArgsToArgs
@Deprecated public static IRubyObject[] openArgsToArgs(Ruby runtime, IRubyObject firstElement, RubyHash options) Deprecated. -
openArgsToArgs
@Deprecated public static IRubyObject[] openArgsToArgs(ThreadContext context, IRubyObject firstElement, RubyHash options) Deprecated. -
extractBinmode
Deprecated. -
extractBinmode
-
ascii8bitEncoding
-
vmodeVperm
Deprecated. -
vmode
Deprecated. -
vmode
Deprecated. -
vperm
Deprecated. -
vperm
Deprecated. -
vmode
-
vmode
-
vperm
-
vperm
-
MODE_BTMODE
public static final int MODE_BTMODE(int fmode, int a, int b, int c) -
SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2
public static int SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(org.jcodings.Encoding enc2, int ecflags) -
extractModeEncoding
@Deprecated public static void extractModeEncoding(ThreadContext context, IOEncodable ioEncodable, Object vmodeAndVperm_p, IRubyObject options, int[] oflags_p, int[] fmode_p) Deprecated. -
extractModeEncoding
public static void extractModeEncoding(ThreadContext context, IOEncodable ioEncodable, API.ModeAndPermission vmodeAndVperm_p, IRubyObject options, int[] oflags_p, int[] fmode_p) -
ioExtractEncodingOption
public static boolean ioExtractEncodingOption(ThreadContext context, IOEncodable ioEncodable, IRubyObject options, int[] fmode_p) -
newExternalStringWithEncoding
public static RubyString newExternalStringWithEncoding(Ruby runtime, String string, org.jcodings.Encoding encoding) -
newExternalStringWithEncoding
public static RubyString newExternalStringWithEncoding(Ruby runtime, ByteList bytelist, org.jcodings.Encoding encoding) -
ioExtIntToEncs
public static void ioExtIntToEncs(ThreadContext context, IOEncodable encodable, org.jcodings.Encoding external, org.jcodings.Encoding internal, int fmode) -
parseModeEncoding
public static void parseModeEncoding(ThreadContext context, IOEncodable ioEncodable, String option, int[] fmode_p) -
econvStrConvert
public static ByteList econvStrConvert(ThreadContext context, org.jcodings.transcode.EConv ec, ByteList src, int flags) -
econvByteConvert
public static ByteList econvByteConvert(ThreadContext context, org.jcodings.transcode.EConv ec, byte[] bytes, int start, int length, int flags) -
econvSubstrAppend
public static ByteList econvSubstrAppend(ThreadContext context, org.jcodings.transcode.EConv ec, ByteList src, ByteList dst, int flags) -
econvAppend
public static ByteList econvAppend(ThreadContext context, org.jcodings.transcode.EConv ec, ByteList sByteList, ByteList dst, int flags) -
econvAppend
public static ByteList econvAppend(ThreadContext context, org.jcodings.transcode.EConv ec, byte[] bytes, int start, int length, ByteList dst, int flags) -
econvCheckError
-
econvPrepareOpts
-
econvPrepareOptions
public static int econvPrepareOptions(ThreadContext context, IRubyObject opthash, IRubyObject[] opts, int ecflags) -
econvOpts
-
econvOpenOpts
public static org.jcodings.transcode.EConv econvOpenOpts(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags, IRubyObject opthash) -
econvOpenExc
public static RaiseException econvOpenExc(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags) -
econvDescription
public static String econvDescription(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags, String message) -
econvAsciicompatEncoding
public static org.jcodings.Encoding econvAsciicompatEncoding(org.jcodings.Encoding enc) -
encAsciicompat
public static boolean encAsciicompat(org.jcodings.Encoding enc) -
encAscget
public static int encAscget(byte[] pBytes, int p, int e, int[] len, org.jcodings.Encoding enc) -
encMbminlen
public static int encMbminlen(org.jcodings.Encoding encoding) -
encDummy
public static boolean encDummy(org.jcodings.Encoding enc) -
encGet
-
encodingEqual
public static boolean encodingEqual(byte[] enc1, byte[] enc2) -
encArg
public static org.jcodings.Encoding encArg(ThreadContext context, IRubyObject encval, byte[][] name_p, org.jcodings.Encoding[] enc_p) -
toEncodingIndex
-
encodedDup
public static RubyString encodedDup(ThreadContext context, RubyString str, org.jcodings.Encoding encindex, RubyString newstr) -
strEncodeAssociate
-
encAssociateIndex
-
strEncode
-
strEncode
-
strEncode
public static IRubyObject strEncode(ThreadContext context, RubyString str, IRubyObject toEncoding, IRubyObject forcedEncoding) -
strEncode
public static IRubyObject strEncode(ThreadContext context, RubyString str, IRubyObject toEncoding, IRubyObject forcedEncoding, IRubyObject opts) -
rbStrEncode
public static IRubyObject rbStrEncode(ThreadContext context, IRubyObject str, IRubyObject to, int ecflags, IRubyObject ecopt) -
rbByteEncode
public static ByteList rbByteEncode(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, int cr, org.jcodings.Encoding to, int ecflags, IRubyObject ecopt) A version of rbStrEncode that works directly with bytes. MRI: rb_str_encode but consuming only a byte array range and producing a ByteList.- Parameters:
context
-bytes
-start
-length
-encoding
-cr
-to
-ecflags
-ecopt
-- Returns:
-
noDecorators
protected static boolean noDecorators(int ecflags) -
strTranscode
public static IRubyObject strTranscode(ThreadContext context, RubyString str, EncodingUtils.TranscodeResult result) -
strTranscode
public static IRubyObject strTranscode(ThreadContext context, IRubyObject toEncoding, RubyString str, EncodingUtils.TranscodeResult result) -
strTranscode
public static IRubyObject strTranscode(ThreadContext context, IRubyObject toEncoding, IRubyObject forcedEncoding, RubyString str, EncodingUtils.TranscodeResult result) -
strTranscode
public static IRubyObject strTranscode(ThreadContext context, IRubyObject toEncoding, IRubyObject forcedEncoding, IRubyObject opts, RubyString str, EncodingUtils.TranscodeResult result) -
objEncoding
-
strTranscodeEncArgs
public static org.jcodings.Encoding strTranscodeEncArgs(ThreadContext context, IRubyObject str, IRubyObject arg1, IRubyObject arg2, byte[][] sname_p, org.jcodings.Encoding[] senc_p, byte[][] dname_p, org.jcodings.Encoding[] denc_p) -
encRegistered
public static boolean encRegistered(byte[] name) -
encCheckDuplication
-
encReplicate
public static org.jcodings.Encoding encReplicate(ThreadContext context, byte[] name, org.jcodings.Encoding encoding) -
defineDummyEncoding
-
DECORATOR_P
public static boolean DECORATOR_P(byte[] sname, byte[] dname) -
strConvEncOpts
public static ByteList strConvEncOpts(ThreadContext context, ByteList str, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding, int ecflags, IRubyObject ecopts) -
strConvEncOpts
public static RubyString strConvEncOpts(ThreadContext context, RubyString str, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding, int ecflags, IRubyObject ecopts) This will try and transcode the supplied ByteList to the supplied toEncoding. It will use forceEncoding as its encoding if it is supplied; otherwise it will use the encoding it has tucked away in the bytelist. This will return a new copy of a ByteList in the request encoding or die trying (ConverterNotFound). c: rb_str_conv_enc_opts -
strConvEnc
public static RubyString strConvEnc(ThreadContext context, RubyString value, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding) -
strConvEnc
public static ByteList strConvEnc(ThreadContext context, ByteList value, org.jcodings.Encoding fromEncoding, org.jcodings.Encoding toEncoding) -
setStrBuf
-
encodingNames
-
transcodeLoop
public static void transcodeLoop(ThreadContext context, byte[] inBytes, org.jcodings.Ptr inPos, byte[] outBytes, org.jcodings.Ptr outPos, int inStop, int _outStop, ByteList destination, EncodingUtils.ResizeFunction resizeFunction, byte[] sname, byte[] dname, int ecflags, IRubyObject ecopts) Perform the inner transcoding loop. This version will determine fallback function and encoding options from the given options object. MRI: transcode_loop Ruby-related bits -
transcodeString
public static ByteList transcodeString(String string, org.jcodings.Encoding toEncoding, int ecflags) A version of transcodeLoop for working without any Ruby runtime available. MRI: transcode_loop with no fallback and java.lang.String input -
getUTF16ForPlatform
public static org.jcodings.Encoding getUTF16ForPlatform() -
transcodeLoop
public static <Data> boolean transcodeLoop(org.jcodings.transcode.EConv ec, EncodingUtils.TranscodeFallback<Data> fallbackFunc, ThreadContext context, Data fallbackData, byte[] inBytes, org.jcodings.Ptr inPos, byte[] outBytes, org.jcodings.Ptr outPos, int inStop, int outStop, ByteList destination, EncodingUtils.ResizeFunction resizeFunction) Perform the inner transcoding loop. The data in inBytes will be transcoded from the source encoding to the destination, eventually replacing the contents of the given ByteList. Along the way, invalid characters may be handled by calling the fallback function (if non-null) with the given state and data. If the destination needs to be resized, use the given function to do so. Upon completion, destination will contain the resulting transcoded bytes. MRI: transcode_loop generified with EConv and fallback function provided- Type Parameters:
Data
- type of data for the fallback function- Parameters:
ec
- the encoding converterfallbackFunc
- the fallback function for non-transcodable characters, or null if nonecontext
- runtime state to pass into the fallbackfallbackData
- call state to pass into the fallbackinBytes
- the incoming byte arrayinPos
- the position from which to start in the incoming bytearrayoutBytes
- the initial output byte arrayoutPos
- the position from which to start in the initial output byte arrayinStop
- the position at which to stop in the inputoutStop
- the number of bytes at which to stop in the outputdestination
- the ByteList to hold the eventual outputresizeFunction
- a function to use to grow the destination- Returns:
-
makeEconvException
@Deprecated(since="10.0") public static RaiseException makeEconvException(Ruby runtime, org.jcodings.transcode.EConv ec) Deprecated. -
makeEconvException
public static RaiseException makeEconvException(ThreadContext context, org.jcodings.transcode.EConv ec) -
ioSetEncodingByBOM
-
ioStripBOM
-
validateEncodingBinmode
public static void validateEncodingBinmode(ThreadContext context, int[] fmode_p, int ecflags, IOEncodable ioEncodable) -
rbEncSetDefaultExternal
-
rbEncSetDefaultInternal
-
encSetDefaultEncoding
public static boolean encSetDefaultEncoding(ThreadContext context, org.jcodings.Encoding[] def_p, IRubyObject encoding, String name) -
defaultExternalEncoding
-
rbStrBufCat
-
rbStrBufCat
-
rbStrBufCat
-
strBufCat
-
strBufCat
-
strBufCat
-
encStrBufCat
public static void encStrBufCat(Ruby runtime, RubyString str, ByteList ptr, org.jcodings.Encoding enc) -
encStrBufCat
-
encStrBufCat
-
encStrBufCat
public static void encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes, org.jcodings.Encoding enc) -
encStrBufCat
public static void encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes, int ptr, int len, org.jcodings.Encoding enc) -
encStrBufCat
-
encCrStrBufCat
public static int encCrStrBufCat(Ruby runtime, CodeRangeable str, ByteList ptr, org.jcodings.Encoding ptrEnc, int ptr_cr) -
encCrStrBufCat
public static int encCrStrBufCat(Ruby runtime, CodeRangeable str, byte[] ptrBytes, int ptr, int len, org.jcodings.Encoding ptrEnc, int ptr_cr) -
econvArgs
public static void econvArgs(ThreadContext context, IRubyObject[] args, byte[][] encNames, org.jcodings.Encoding[] encs, int[] ecflags_p, IRubyObject[] ecopts_p) -
econvInitByConvpath
public static org.jcodings.transcode.EConv econvInitByConvpath(ThreadContext context, IRubyObject convpathArg, byte[][] encNames, org.jcodings.Encoding[] encs) -
decorateConvpath
-
ioEncStr
-
ioEncStr
-
encUintChr
-
encMbcput
public static int encMbcput(int c, byte[] buf, int p, org.jcodings.Encoding enc) -
encMbcput
public static int encMbcput(ThreadContext context, int c, byte[] buf, int p, org.jcodings.Encoding enc) -
encCodepointLength
public static int encCodepointLength(byte[] pBytes, int p, int e, int[] len_p, org.jcodings.Encoding enc) -
encCodepointLength
@Deprecated public static int encCodepointLength(Ruby runtime, byte[] pBytes, int p, int e, int[] len_p, org.jcodings.Encoding enc) Deprecated. -
encCodepointLength
public static int encCodepointLength(ThreadContext context, byte[] pBytes, int p, int e, int[] len_p, org.jcodings.Encoding enc) -
strCompatAndValid
public static IRubyObject strCompatAndValid(ThreadContext context, IRubyObject _str, org.jcodings.Encoding enc) -
getEncoding
-
getActualEncoding
-
getActualEncoding
public static org.jcodings.Encoding getActualEncoding(org.jcodings.Encoding enc, byte[] bytes, int p, int end) -
STR_ENC_GET
-
rbStrEscape
Deprecated. -
isPrint
public static boolean isPrint(int c) -
rbStrBufCatEscapedChar
-
charsetForEncoding
public static Charset charsetForEncoding(org.jcodings.Encoding enc) throws UnsupportedCharsetException Get an appropriate Java Charset for the given Encoding. This works around a bug in jcodings where it would return null as the charset for encodings that should have a match, like Windows-1252. This method is equivalent to enc.getCharset in jcodings 1.0.25 and higher. See https://github.com/jruby/jruby/issues/4716 for more information.- Parameters:
enc
- the encoding for which to get a matching charset- Returns:
- the matching charset
- Throws:
UnsupportedCharsetException
-
encCodelen
-
rbAscii8bitAppendableEncodingIndex
public static org.jcodings.Encoding rbAscii8bitAppendableEncodingIndex(ThreadContext context, org.jcodings.Encoding enc, int code) -
ioStripBOM
Deprecated. -
strTranscode0
@Deprecated public static org.jcodings.Encoding strTranscode0(ThreadContext context, int argc, IRubyObject[] args, IRubyObject[] self_p, int ecflags, IRubyObject ecopts) Deprecated. -
strTranscode
@Deprecated public static org.jcodings.Encoding strTranscode(ThreadContext context, IRubyObject[] args, IRubyObject[] self_p) Deprecated. -
strEncode
@Deprecated public static IRubyObject strEncode(ThreadContext context, IRubyObject str, IRubyObject... args) Deprecated. -
encodedDup
@Deprecated public static IRubyObject encodedDup(ThreadContext context, IRubyObject newstr, IRubyObject str, org.jcodings.Encoding encindex) Deprecated. -
strEncodeAssociate
@Deprecated public static IRubyObject strEncodeAssociate(ThreadContext context, IRubyObject str, org.jcodings.Encoding encidx) Deprecated. -
strTranscode
@Deprecated public static IRubyObject strTranscode(ThreadContext context, IRubyObject[] args, RubyString str, EncodingUtils.TranscodeResult result) Deprecated.
-