Top Inners Fields Constructors Methods
org.jruby.util.io

public Class EncodingUtils

extends Object
Class Inheritance
Imports
org.jcodings.Encoding, .EncodingDB, .Ptr, org.jcodings.ascii.AsciiTables, org.jcodings.exception.EncodingError, .EncodingException, .ErrorCodes, org.jcodings.specific.ASCIIEncoding, .USASCIIEncoding, .UTF16BEEncoding, .UTF16LEEncoding, .UTF32BEEncoding, .UTF32LEEncoding, .UTF8Encoding, org.jcodings.transcode.EConv, .EConvFlags, .EConvResult, .Transcoder, .TranscoderDB, .Transcoding, org.jcodings.unicode.UnicodeEncoding, org.jruby.Ruby, .RubyArray, .RubyBasicObject, .RubyConverter, .RubyEncoding, .RubyFixnum, .RubyHash, .RubyIO, .RubyInteger, .RubyMethod, .RubyNumeric, .RubyProc, .RubyString, .RubySymbol, org.jruby.api.API, .Convert, org.jruby.exceptions.RaiseException, org.jruby.platform.Platform, org.jruby.runtime.Block, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.encoding.EncodingCapable, .EncodingService, org.jruby.util.ByteList, .ByteListHolder, .CodeRangeSupport, .CodeRangeable, .StringSupport, .TypeConverter, java.nio.charset.Charset, .UnsupportedCharsetException, java.util.ArrayList, .Arrays, .List

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
public static interface
public static interface
EncodingUtils.TranscodeFallback<
Data needed for the function to execute
Data
>

Fallback function to provide replacements for characters that fail to transcode.

public static interface

Field Summary

Modifier and TypeField and Description
private static final EncodingUtils.AbstractTranscodeFallback
public static final int
public static final int
private static final EncodingUtils.AbstractTranscodeFallback
private static final EncodingUtils.AbstractTranscodeFallback
private static final byte[]
private static final EncodingUtils.AbstractTranscodeFallback
public static final EncodingUtils.ResizeFunction
public static final int
private static final Encoding
private static final Encoding

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Encoding
public static Charset

Returns:

the matching charset
charsetForEncoding
(Encoding
the encoding for which to get a matching charset
enc
)

Get an appropriate Java Charset for the given Encoding.

public static int
decorateConvpath(ThreadContext context, IRubyObject convpath, int ecflags)

public static boolean
DECORATOR_P(byte[] sname, byte[] dname)

public static Encoding
public static Encoding
defineDummyEncoding(ThreadContext context, byte[] name)

public static ByteList
econvAppend(ThreadContext context, EConv ec, ByteList sByteList, ByteList dst, int flags)

public static ByteList
econvAppend(ThreadContext context, EConv ec, byte[] bytes, int start, int length, ByteList dst, int flags)

public static void
econvArgs(ThreadContext context, IRubyObject[] args, byte[][] encNames, Encoding[] encs, int[] ecflags_p, IRubyObject[] ecopts_p)

public static Encoding
public static ByteList
econvByteConvert(ThreadContext context, EConv ec, byte[] bytes, int start, int length, int flags)

public static void
public static String
econvDescription(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags, String message)

public static EConv
econvInitByConvpath(ThreadContext context, IRubyObject convpathArg, byte[][] encNames, Encoding[] encs)

public static RaiseException
econvOpenExc(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags)

public static EConv
econvOpenOpts(ThreadContext context, byte[] sourceEncoding, byte[] destinationEncoding, int ecflags, IRubyObject opthash)

public static int
econvOpts(ThreadContext context, IRubyObject opt, int ecflags)

public static int
econvPrepareOptions(ThreadContext context, IRubyObject opthash, IRubyObject[] opts, int ecflags)

public static int
public static ByteList
econvStrConvert(ThreadContext context, EConv ec, ByteList src, int flags)

public static ByteList
econvSubstrAppend(ThreadContext context, EConv ec, ByteList src, ByteList dst, int flags)

public static Encoding
encArg(ThreadContext context, IRubyObject encval, byte[][] name_p, Encoding[] enc_p)

public static int
encAscget(byte[] pBytes, int p, int e, int[] len, Encoding enc)

public static boolean
public static IRubyObject
public static void
encCheckDuplication(ThreadContext context, byte[] name)

public static int
encCodelen(ThreadContext context, int c, Encoding enc)

public static int
encCodepointLength(byte[] pBytes, int p, int e, int[] len_p, Encoding enc)

public static int
encCodepointLength(Ruby runtime, byte[] pBytes, int p, int e, int[] len_p, Encoding enc)
Deprecated

public static int
encCodepointLength(ThreadContext context, byte[] pBytes, int p, int e, int[] len_p, Encoding enc)

public static int
encCrStrBufCat(Ruby runtime, CodeRangeable str, ByteList ptr, Encoding ptrEnc, int ptr_cr)

public static int
encCrStrBufCat(Ruby runtime, CodeRangeable str, byte[] ptrBytes, int ptr, int len, Encoding ptrEnc, int ptr_cr)

public static boolean
public static Encoding
public static int
encMbcput(int c, byte[] buf, int p, Encoding enc)

public static int
encMbcput(ThreadContext context, int c, byte[] buf, int p, Encoding enc)

public static int
public static RubyString
encodedDup(ThreadContext context, RubyString str, Encoding encindex, RubyString newstr)

public static IRubyObject
encodedDup(ThreadContext context, IRubyObject newstr, IRubyObject str, Encoding encindex)
Deprecated

public static boolean
encodingEqual(byte[] enc1, byte[] enc2)

public static List<String>
encodingNames(byte[] name, int p, int end)

public static boolean
encRegistered(byte[] name)

public static Encoding
encReplicate(ThreadContext context, byte[] name, Encoding encoding)

public static boolean
public static void
encStrBufCat(Ruby runtime, RubyString str, ByteList ptr, Encoding enc)

public static void
encStrBufCat(Ruby runtime, RubyString str, ByteList ptr)

public static void
encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes)

public static void
encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes, Encoding enc)

public static void
encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes, int ptr, int len, Encoding enc)

public static void
public static RubyString
encUintChr(ThreadContext context, int code, Encoding enc)

public static void
extractBinmode(Ruby runtime, IRubyObject optionsArg, int[] fmode_p)
Deprecated

public static void
extractBinmode(ThreadContext context, IRubyObject optionsArg, int[] fmode_p)

public static void
extractModeEncoding(ThreadContext context, IOEncodable ioEncodable, Object vmodeAndVperm_p, IRubyObject options, int[] oflags_p, int[] fmode_p)
Deprecated

public static void
extractModeEncoding(ThreadContext context, IOEncodable ioEncodable, API.ModeAndPermission vmodeAndVperm_p, IRubyObject options, int[] oflags_p, int[] fmode_p)

public static Encoding
public static Encoding
getActualEncoding(Encoding enc, byte[] bytes, int p, int end)

public static Encoding
public static Encoding
private static IRubyObject
hashARef(ThreadContext context, IRubyObject hash, String symbol)

public static RubyString
ioEncStr(Ruby runtime, RubyString str, OpenFile fptr)

public static IRubyObject
ioEncStr(Ruby runtime, IRubyObject str, OpenFile fptr)

public static void
ioExtIntToEncs(ThreadContext context, IOEncodable encodable, Encoding external, Encoding internal, int fmode)

public static boolean
ioExtractEncodingOption(ThreadContext context, IOEncodable ioEncodable, IRubyObject options, int[] fmode_p)

public static Encoding
public static Encoding
public static Encoding
ioStripBOM(RubyIO io)
Deprecated

private static boolean
private static boolean
is7BitCompat(int cr, Encoding denc, Encoding senc)

public static boolean
isPrint(int c)

public static RaiseException
makeEconvException(Ruby runtime, EConv ec)
Deprecated since 10.0.

public static RaiseException
private static RaiseException
public static final int
MODE_BTMODE(int fmode, int a, int b, int c)

pack-priv static void
moreOutputBuffer(ByteList destination, EncodingUtils.ResizeFunction resizeDestination, int maxOutput, Ptr outStart, Ptr outPos, Ptr outStop)

public static RubyString
public static RubyString
newExternalStringWithEncoding(Ruby runtime, ByteList bytelist, Encoding encoding)

protected static boolean
noDecorators(int ecflags)

public static IRubyObject
public static IRubyObject[]
openArgsToArgs(Ruby runtime, IRubyObject firstElement, RubyHash options)
Deprecated

public static IRubyObject[]
openArgsToArgs(ThreadContext context, IRubyObject firstElement, RubyHash options)
Deprecated

public static void
parseModeEncoding(ThreadContext context, IOEncodable ioEncodable, String option, int[] fmode_p)

public static Encoding
public static ByteList
rbByteEncode(ThreadContext context, byte[] bytes, int start, int length, Encoding encoding, int cr, Encoding to, int ecflags, IRubyObject ecopt)

A version of rbStrEncode that works directly with bytes.

public static void
public static void
public static void
rbStrBufCat(Ruby runtime, RubyString str, ByteList ptr)

public static void
rbStrBufCat(Ruby runtime, ByteListHolder str, byte[] ptrBytes, int ptr, int len)

public static void
rbStrBufCat(Ruby runtime, ByteList str, byte[] ptrBytes, int ptr, int len)

public static int
rbStrBufCatEscapedChar(RubyString result, long c, boolean unicode_p)

public static IRubyObject
rbStrEncode(ThreadContext context, IRubyObject str, IRubyObject to, int ecflags, IRubyObject ecopt)

public static RubyString
rbStrEscape(Ruby runtime, RubyString str)
Deprecated since 10.0.

public static Encoding
public static int
public static RubyString
setStrBuf(Ruby runtime, final IRubyObject obj, final int len)

public static Encoding
public static void
strBufCat(Ruby runtime, RubyString str, ByteList ptr)

public static void
strBufCat(Ruby runtime, ByteListHolder str, byte[] ptrBytes, int ptr, int len)

public static void
strBufCat(ByteList str, byte[] ptrBytes, int ptr, int len)

public static IRubyObject
public static RubyString
strConvEnc(ThreadContext context, RubyString value, Encoding fromEncoding, Encoding toEncoding)

public static ByteList
strConvEnc(ThreadContext context, ByteList value, Encoding fromEncoding, Encoding toEncoding)

public static ByteList
strConvEncOpts(ThreadContext context, ByteList str, Encoding fromEncoding, Encoding toEncoding, int ecflags, IRubyObject ecopts)

public static RubyString
strConvEncOpts(ThreadContext context, RubyString str, Encoding fromEncoding, Encoding toEncoding, int ecflags, IRubyObject ecopts)

This will try and transcode the supplied ByteList to the supplied toEncoding.

public static IRubyObject
public static IRubyObject
strEncode(ThreadContext context, RubyString str, IRubyObject toEncoding)

public static IRubyObject
strEncode(ThreadContext context, RubyString str, IRubyObject toEncoding, IRubyObject forcedEncoding)

public static IRubyObject
strEncode(ThreadContext context, RubyString str, IRubyObject toEncoding, IRubyObject forcedEncoding, IRubyObject opts)

public static IRubyObject
strEncode(ThreadContext context, IRubyObject str, IRubyObject... args)
Deprecated

public static RubyString
public static IRubyObject
strEncodeAssociate(ThreadContext context, IRubyObject str, Encoding encidx)
Deprecated

public static IRubyObject
public static IRubyObject
public static IRubyObject
strTranscode(ThreadContext context, IRubyObject toEncoding, IRubyObject forcedEncoding, RubyString str, EncodingUtils.TranscodeResult result)

public static IRubyObject
strTranscode(ThreadContext context, IRubyObject toEncoding, IRubyObject forcedEncoding, IRubyObject opts, RubyString str, EncodingUtils.TranscodeResult result)

private static RubyString
strTranscode(ThreadContext context, IRubyObject toEncoding, IRubyObject forceEncoding, RubyString str, int ecflags, IRubyObject ecopts, EncodingUtils.TranscodeResult result, boolean explicitlyInvalidReplace)

public static Encoding
strTranscode(ThreadContext context, IRubyObject[] args, IRubyObject[] self_p)
Deprecated

public static IRubyObject
private static IRubyObject
public static Encoding
strTranscode0(ThreadContext context, int argc, IRubyObject[] args, IRubyObject[] self_p, int ecflags, IRubyObject ecopts)
Deprecated

private static IRubyObject
strTranscode1(ThreadContext context, IRubyObject toEncoding, RubyString str, int ecflags, IRubyObject ecopts, EncodingUtils.TranscodeResult result)

private static IRubyObject
strTranscode2(ThreadContext context, IRubyObject toEncoding, IRubyObject forceEncoding, RubyString str, int ecflags, IRubyObject ecopts, EncodingUtils.TranscodeResult result)

public static Encoding
strTranscodeEncArgs(ThreadContext context, IRubyObject str, IRubyObject arg1, IRubyObject arg2, byte[][] sname_p, Encoding[] senc_p, byte[][] dname_p, Encoding[] denc_p)

private static RubyString
strTranscodeScrub(ThreadContext context, IRubyObject forceEncoding, RubyString str, int ecflags, IRubyObject ecopts, EncodingUtils.TranscodeResult result, boolean explicitlyInvalidReplace, Encoding denc, Encoding senc)

public static Encoding
public static Encoding
public static void
transcodeLoop(ThreadContext context, byte[] inBytes, Ptr inPos, byte[] outBytes, Ptr outPos, int inStop, int _outStop, ByteList destination, EncodingUtils.ResizeFunction resizeFunction, byte[] sname, byte[] dname, int ecflags, IRubyObject ecopts)

Perform the inner transcoding loop.

public static <
type of data for the fallback function
Data
>
boolean
transcodeLoop(EConv
the encoding converter
ec
,
EncodingUtils.TranscodeFallback<Data>
the fallback function for non-transcodable characters, or null if none
fallbackFunc
,
ThreadContext
runtime state to pass into the fallback
context
,
Data
call state to pass into the fallback
fallbackData
,
byte[]
the incoming byte array
inBytes
,
Ptr
the position from which to start in the incoming bytearray
inPos
,
byte[]
the initial output byte array
outBytes
,
Ptr
the position from which to start in the initial output byte array
outPos
,
int
the position at which to stop in the input
inStop
,
int
the number of bytes at which to stop in the output
outStop
,
ByteList
the ByteList to hold the eventual output
destination
,
EncodingUtils.ResizeFunction
a function to use to grow the destination
resizeFunction
)

Perform the inner transcoding loop.

public static ByteList
transcodeString(String string, Encoding toEncoding, int ecflags)

A version of transcodeLoop for working without any Ruby runtime available.

public static void
validateEncodingBinmode(ThreadContext context, int[] fmode_p, int ecflags, IOEncodable ioEncodable)

public static IRubyObject
vmode(Object vmodeVperm)
Deprecated

public static void
vmode(Object vmodeVperm, IRubyObject vmode)
Deprecated

public static IRubyObject
public static void
public static Object
vmodeVperm(IRubyObject vmode, IRubyObject vperm)
Deprecated

public static IRubyObject
vperm(Object vmodeVperm)
Deprecated

public static void
vperm(Object vmodeVperm, IRubyObject vperm)
Deprecated

public static IRubyObject
public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait