@Override public String getCharset() { return encoding.getCharsetName(); }
private void setEncoding(String name) { EncodingDB.Entry e = EncodingDB.getEncodings().get(Bytes.toBytes(name)); if (e != null) { encoding = e.getEncoding(); } else { throw new IllegalCharsetNameException(name); } } }
private boolean isInClassMB() { int tlen = code[ip++]; if (s >= range) return false; int mbLen = enc.length(bytes, s, end); if (s + mbLen > range) return false; int ss = s; s += mbLen; int c = enc.mbcToCode(bytes, ss, s); if (!CodeRange.isInCodeRange(code, ip, c)) return false; ip += tlen; return true; }
private RubyEncoding loadEncodingEntry(final Entry entry) { Encoding enc = entry.getEncoding(); // load the encoding int index = enc.getIndex(); RubyEncoding[] encodingIndex = this.encodingIndex; if (index >= encodingIndex.length) { encodingIndex = this.encodingIndex = Arrays.copyOf(encodingIndex, index + 4); } return encodingIndex[index] = (RubyEncoding) encodingList[entry.getIndex()]; }
public static int octLength(byte[]bytes, int p, int len, Encoding enc) { int olen = 0; int c; while (len-- > 0 && enc.isDigit(c = bytes[p++] & 0xff) && c < '8') olen++; return olen; }
public static int searchNonAscii(byte[]bytes, int p, int end) { while (p < end) { if (!Encoding.isAscii(bytes[p])) return p; p++; } return -1; }
public static int hexLength(byte[]bytes, int p, int len, Encoding enc) { int hlen = 0; while (len-- > 0 && enc.isXDigit(bytes[p++] & 0xff)) hlen++; return hlen; }
public boolean canBeSplit(Encoding enc) { if (end > p) { return enc.length(bytes, p, end) < (end - p); } return false; }
static int positionValue(Encoding enc, int i) { if (i < ByteValTable.length) { if (i == 0 && enc.minLength() > 1) { return 20; } else { return ByteValTable[i]; } } else { return 4; /* Take it easy. */ } }
/** * Number of characters in this ByteList based on its current encoding. * * @return number of characters */ public int lengthEnc() { return encoding.strLength(bytes, begin, begin + realSize); }
/** * Get the index code point in this ByteList. * * @param index is the element you want * @return the element you requested */ public int getEnc(int index) { return encoding.strCodeAt(bytes, begin, begin + realSize, index); }
private void setEncoding(String name) { EncodingDB.Entry e = EncodingDB.getEncodings().get(Bytes.toBytes(name)); if (e != null) { encoding = e.getEncoding(); } else { throw new IllegalCharsetNameException(name); } } }
private boolean isInClassMB() { int tlen = code[ip++]; if (s >= range) return false; int mbLen = enc.length(bytes, s, end); if (s + mbLen > range) return false; int ss = s; s += mbLen; int c = enc.mbcToCode(bytes, ss, s); if (!CodeRange.isInCodeRange(code, ip, c)) return false; ip += tlen; return true; }
@Override public String getCharset() { return encoding.getCharsetName(); }
public static int octLength(byte[]bytes, int p, int len, Encoding enc) { int olen = 0; int c; while (len-- > 0 && enc.isDigit(c = bytes[p++] & 0xff) && c < '8') olen++; return olen; }
/** * Number of characters in this ByteList based on its current encoding. * * @return number of characters */ public int lengthEnc() { return encoding.strLength(bytes, begin, begin + realSize); }
@Override public byte[] toByteArray() { ComparatorProtos.RegexStringComparator.Builder builder = ComparatorProtos.RegexStringComparator.newBuilder(); builder.setPattern(regex); builder.setPatternFlags(joniToPatternFlags(pattern.getOptions())); builder.setCharset(encoding.getCharsetName()); builder.setEngine(EngineType.JONI.name()); return builder.build().toByteArray(); }
@Override public byte[] toByteArray() { ComparatorProtos.RegexStringComparator.Builder builder = ComparatorProtos.RegexStringComparator.newBuilder(); builder.setPattern(regex); builder.setPatternFlags(joniToPatternFlags(pattern.getOptions())); builder.setCharset(encoding.getCharsetName()); builder.setEngine(EngineType.JONI.name()); return builder.build().toByteArray(); }