public TR(ByteList bytes) { p = bytes.getBegin(); pend = bytes.getRealSize() + p; buf = bytes.getUnsafeBytes(); now = max = 0; gen = false; }
private static int javaStringHashCode(ByteList iso8859) { int h = 0; int length = iso8859.length(); if (length > 0) { byte val[] = iso8859.getUnsafeBytes(); int begin = iso8859.begin(); h = new String(val, begin, length, RubyEncoding.ISO).hashCode(); } return h; }
private static boolean lastCharDigit(RubyString str) { ByteList bytes = str.getByteList(); return ASCIIEncoding.INSTANCE.isDigit(bytes.getUnsafeBytes()[bytes.getBegin() + bytes.getRealSize() - 1]); }
@Deprecated public static Object coerceStringToType(RubyString string, Class target) { try { ByteList bytes = string.getByteList(); // 1.9 support for encodings // TODO: Fix charset use for JRUBY-4553 return new String(bytes.getUnsafeBytes(), bytes.begin(), bytes.length(), string.getEncoding().toString()); } catch (UnsupportedEncodingException uee) { return string.toString(); } }
private RubyString strioSubstr(Ruby runtime, int pos, int len) { RubyString str = ptr.string; ByteList strByteList = str.getByteList(); byte[] strBytes = strByteList.getUnsafeBytes(); Encoding enc = str.getEncoding(); int rlen = str.size() - pos; if (len > rlen) len = rlen; if (len < 0) len = 0; if (len == 0) return RubyString.newEmptyString(runtime); return RubyString.newStringShared(runtime, strBytes, strByteList.getBegin() + pos, len, enc); }
/** * This looks deceptively like tokadd_mbchar(int, ByteList) but it differs in that it uses * the bytelists encoding and the first parameter is a full codepoint and not the first byte * of a mbc sequence. */ public void tokaddmbc(int codepoint, ByteList buffer) { Encoding encoding = buffer.getEncoding(); int length = encoding.codeToMbcLength(codepoint); buffer.ensure(buffer.getRealSize() + length); encoding.codeToMbc(codepoint, buffer.getUnsafeBytes(), buffer.begin() + buffer.getRealSize()); buffer.setRealSize(buffer.getRealSize() + length); }
public int precise_mbclen() { byte[] data = lexb.getUnsafeBytes(); int begin = lexb.begin(); // we subtract one since we have read past first byte by time we are calling this. return current_enc.length(data, begin + lex_p - 1, begin + lex_pend); }
private static boolean lastCharDigit(RubyString str) { ByteList bytes = str.getByteList(); return ASCIIEncoding.INSTANCE.isDigit(bytes.getUnsafeBytes()[bytes.getBegin() + bytes.getRealSize() - 1]); }
@Deprecated public static Object coerceStringToType(RubyString string, Class target) { try { ByteList bytes = string.getByteList(); // 1.9 support for encodings // TODO: Fix charset use for JRUBY-4553 return new String(bytes.getUnsafeBytes(), bytes.begin(), bytes.length(), string.getEncoding().toString()); } catch (UnsupportedEncodingException uee) { return string.toString(); } }
private static int javaStringHashCode(ByteList iso8859) { int h = 0; int length = iso8859.length(); if (length > 0) { byte val[] = iso8859.getUnsafeBytes(); int begin = iso8859.begin(); h = new String(val, begin, length, RubyEncoding.ISO).hashCode(); } return h; }
public TR(ByteList bytes) { p = bytes.getBegin(); pend = bytes.getRealSize() + p; buf = bytes.getUnsafeBytes(); now = max = 0; gen = false; }
private RubyString strioSubstr(Ruby runtime, int pos, int len) { RubyString str = ptr.string; ByteList strByteList = str.getByteList(); byte[] strBytes = strByteList.getUnsafeBytes(); Encoding enc = str.getEncoding(); int rlen = str.size() - pos; if (len > rlen) len = rlen; if (len < 0) len = 0; if (len == 0) return RubyString.newEmptyString(runtime); return RubyString.newStringShared(runtime, strBytes, strByteList.getBegin() + pos, len, enc); }
/** * This looks deceptively like tokadd_mbchar(int, ByteList) but it differs in that it uses * the bytelists encoding and the first parameter is a full codepoint and not the first byte * of a mbc sequence. */ public void tokaddmbc(int codepoint, ByteList buffer) { Encoding encoding = buffer.getEncoding(); int length = encoding.codeToMbcLength(codepoint); buffer.ensure(buffer.getRealSize() + length); encoding.codeToMbc(codepoint, buffer.getUnsafeBytes(), buffer.begin() + buffer.getRealSize()); buffer.setRealSize(buffer.getRealSize() + length); }
private static boolean lastCharDigit(RubyString str) { ByteList bytes = str.getByteList(); return ASCIIEncoding.INSTANCE.isDigit(bytes.getUnsafeBytes()[bytes.getBegin() + bytes.getRealSize() - 1]); }
@JRubyMethod(name = "write_string") public IRubyObject write_string(ThreadContext context, IRubyObject strArg) { ByteList bl = strArg.convertToString().getByteList(); getMemoryIO().put(0, bl.getUnsafeBytes(), bl.begin(), bl.length()); return this; }
public void writeString(ByteList value) throws IOException { int len = value.length(); writeInt(len); out.write(value.getUnsafeBytes(), value.begin(), len); }
public static ByteList addByteLists(ByteList value1, ByteList value2) { ByteList result = new ByteList(value1.getRealSize() + value2.getRealSize()); result.setRealSize(value1.getRealSize() + value2.getRealSize()); System.arraycopy(value1.getUnsafeBytes(), value1.getBegin(), result.getUnsafeBytes(), 0, value1.getRealSize()); System.arraycopy(value2.getUnsafeBytes(), value2.getBegin(), result.getUnsafeBytes(), value1.getRealSize(), value2.getRealSize()); return result; }
private RubyString strioSubstr(Ruby runtime, int pos, int len) { RubyString str = ptr.string; ByteList strByteList = str.getByteList(); byte[] strBytes = strByteList.getUnsafeBytes(); Encoding enc = str.getEncoding(); int rlen = str.size() - pos; if (len > rlen) len = rlen; if (len < 0) len = 0; if (len == 0) return RubyString.newEmptyString(runtime); return RubyString.newStringShared(runtime, strBytes, strByteList.getBegin() + pos, len, enc); }
private static boolean lastCharDigit(RubyString str) { ByteList bytes = str.getByteList(); return ASCIIEncoding.INSTANCE.isDigit(bytes.getUnsafeBytes()[bytes.getBegin() + bytes.getRealSize() - 1]); }
@JRubyMethod(name = "write_string") public IRubyObject write_string(ThreadContext context, IRubyObject strArg) { ByteList bl = strArg.convertToString().getByteList(); getMemoryIO().put(0, bl.getUnsafeBytes(), bl.begin(), bl.length()); return this; }