private static int codeRangeScanAsciiCompatible(Encoding enc, byte[]bytes, int p, int len) { int end = p + len; p = searchNonAscii(bytes, p, end); if (p == -1) return CR_7BIT; while (p < end) { int cl = preciseLength(enc, bytes, p, end); if (cl <= 0) return CR_BROKEN; p += cl; if (p < end) { p = searchNonAscii(bytes, p, end); if (p == -1) return CR_VALID; } } return p > end ? CR_BROKEN : CR_VALID; }
private static int codeRangeScanAsciiCompatible(Encoding enc, byte[]bytes, int p, int len) { int end = p + len; p = searchNonAscii(bytes, p, end); if (p == -1) return CR_7BIT; while (p < end) { int cl = preciseLength(enc, bytes, p, end); if (cl <= 0) return CR_BROKEN; p += cl; if (p < end) { p = searchNonAscii(bytes, p, end); if (p == -1) return CR_VALID; } } return p > end ? CR_BROKEN : CR_VALID; }
private static int codeRangeScanAsciiCompatible(Encoding enc, byte[]bytes, int p, int len) { int end = p + len; p = searchNonAscii(bytes, p, end); if (p == -1) return CR_7BIT; while (p < end) { int cl = preciseLength(enc, bytes, p, end); if (cl <= 0) return CR_BROKEN; p += cl; if (p < end) { p = searchNonAscii(bytes, p, end); if (p == -1) return CR_VALID; } } return p > end ? CR_BROKEN : CR_VALID; }
private static int codeRangeScanAsciiCompatible(Encoding enc, byte[]bytes, int p, int len) { int end = p + len; p = searchNonAscii(bytes, p, end); if (p == -1) return CR_7BIT; while (p < end) { int cl = preciseLength(enc, bytes, p, end); if (cl <= 0) return CR_BROKEN; p += cl; if (p < end) { p = searchNonAscii(bytes, p, end); if (p == -1) return CR_VALID; } } return p > end ? CR_BROKEN : CR_VALID; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
public static int codeRangeScan(Encoding enc, byte[]bytes, int p, int len) { if (enc == ASCIIEncoding.INSTANCE) { return searchNonAscii(bytes, p, p + len) != -1 ? CR_VALID : CR_7BIT; } if (enc.isAsciiCompatible()) { return codeRangeScanAsciiCompatible(enc, bytes, p, len); } return codeRangeScanNonAsciiCompatible(enc, bytes, p, len); }
public static int codeRangeScan(Encoding enc, byte[]bytes, int p, int len) { if (enc == ASCIIEncoding.INSTANCE) { return searchNonAscii(bytes, p, p + len) != -1 ? CR_VALID : CR_7BIT; } if (enc.isAsciiCompatible()) { return codeRangeScanAsciiCompatible(enc, bytes, p, len); } return codeRangeScanNonAsciiCompatible(enc, bytes, p, len); }
public static int codeRangeScan(Encoding enc, byte[]bytes, int p, int len) { if (enc == ASCIIEncoding.INSTANCE) { return searchNonAscii(bytes, p, p + len) != -1 ? CR_VALID : CR_7BIT; } if (enc.isAsciiCompatible()) { return codeRangeScanAsciiCompatible(enc, bytes, p, len); } return codeRangeScanNonAsciiCompatible(enc, bytes, p, len); }
public static int codeRangeScan(Encoding enc, byte[]bytes, int p, int len) { if (enc == ASCIIEncoding.INSTANCE) { return searchNonAscii(bytes, p, p + len) != -1 ? CR_VALID : CR_7BIT; } if (enc.isAsciiCompatible()) { return codeRangeScanAsciiCompatible(enc, bytes, p, len); } return codeRangeScanNonAsciiCompatible(enc, bytes, p, len); }
public static int searchNonAscii(ByteList bytes) { return searchNonAscii(bytes.getUnsafeBytes(), bytes.getBegin(), bytes.getBegin() + bytes.getRealSize()); }
public static int searchNonAscii(ByteList bytes) { return searchNonAscii(bytes.getUnsafeBytes(), bytes.getBegin(), bytes.getBegin() + bytes.getRealSize()); }
public static int searchNonAscii(ByteList bytes) { return searchNonAscii(bytes.getUnsafeBytes(), bytes.getBegin(), bytes.getBegin() + bytes.getRealSize()); }
public static int searchNonAscii(ByteList bytes) { return searchNonAscii(bytes.getUnsafeBytes(), bytes.getBegin(), bytes.getBegin() + bytes.getRealSize()); }
private static long strLengthWithCodeRangeAsciiCompatible(Encoding enc, byte[]bytes, int p, int end) { int cr = 0, c = 0; while (p < end) { if (Encoding.isAscii(bytes[p])) { int q = searchNonAscii(bytes, p, end); if (q == -1) return pack(c + (end - p), cr == 0 ? CR_7BIT : cr); c += q - p; p = q; } int cl = preciseLength(enc, bytes, p, end); if (cl > 0) { cr |= CR_VALID; p += cl; } else { cr = CR_BROKEN; p++; } c++; } return pack(c, cr == 0 ? CR_7BIT : cr); }
public static long strLengthWithCodeRangeAsciiCompatible(Encoding enc, byte[]bytes, int p, int end) { int cr = 0, c = 0; while (p < end) { if (Encoding.isAscii(bytes[p])) { int q = searchNonAscii(bytes, p, end); if (q == -1) return pack(c + (end - p), cr == 0 ? CR_7BIT : cr); c += q - p; p = q; } int cl = preciseLength(enc, bytes, p, end); if (cl > 0) { cr |= CR_VALID; p += cl; } else { cr = CR_BROKEN; p++; } c++; } return pack(c, cr == 0 ? CR_7BIT : cr); }
private void copyCodeRangeForSubstr(RubyString from, Encoding enc) { int fromCr = from.getCodeRange(); if (fromCr == CR_7BIT) { setCodeRange(fromCr); } else if (fromCr == CR_VALID) { if (!enc.isAsciiCompatible() || searchNonAscii(value) != -1) { setCodeRange(CR_VALID); } else { setCodeRange(CR_7BIT); } } else{ if (value.getRealSize() == 0) { setCodeRange(!enc.isAsciiCompatible() ? CR_VALID : CR_7BIT); } } }
private void copyCodeRangeForSubstr(RubyString from, Encoding enc) { int fromCr = from.getCodeRange(); if (fromCr == CR_7BIT) { setCodeRange(fromCr); } else if (fromCr == CR_VALID) { if (!enc.isAsciiCompatible() || searchNonAscii(value) != -1) { setCodeRange(CR_VALID); } else { setCodeRange(CR_7BIT); } } else{ if (value.getRealSize() == 0) { setCodeRange(!enc.isAsciiCompatible() ? CR_VALID : CR_7BIT); } } }