public static int hexLength(byte[]bytes, int p, int len) { return hexLength(bytes, p, len, ASCIIEncoding.INSTANCE); }
public static int hexLength(byte[]bytes, int p, int len) { return hexLength(bytes, p, len, ASCIIEncoding.INSTANCE); }
public static int hexLength(byte[]bytes, int p, int len) { return hexLength(bytes, p, len, ASCIIEncoding.INSTANCE); }
public static int hexLength(byte[]bytes, int p, int len) { return hexLength(bytes, p, len, ASCIIEncoding.INSTANCE); }
/** * Unescape unicode BMP char at given offset, appending to the specified * buffer if non-null. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeBmp(Ruby runtime, ByteList to, byte[] bytes, int p, int end, Encoding[] encp, ByteList str, ErrorMode mode) { if (p + 4 > end) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); int code = StringSupport.scanHex(bytes, p, 4); int len = StringSupport.hexLength(bytes, p, 4); if (len != 4) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); appendUtf8(runtime, to, code, encp, str, mode); return p + 4; }
/** * Unescape unicode BMP char at given offset, appending to the specified * buffer if non-null. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeBmp(Ruby runtime, ByteList to, byte[] bytes, int p, int end, Encoding[] encp, ByteList str, ErrorMode mode) { if (p + 4 > end) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); int code = StringSupport.scanHex(bytes, p, 4); int len = StringSupport.hexLength(bytes, p, 4); if (len != 4) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); appendUtf8(runtime, to, code, encp, str, mode); return p + 4; }
/** * Unescape unicode BMP char at given offset, appending to the specified * buffer if non-null. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeBmp(Ruby runtime, ByteList to, byte[] bytes, int p, int end, Encoding[] encp, ByteList str, ErrorMode mode) { if (p + 4 > end) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); int code = StringSupport.scanHex(bytes, p, 4); int len = StringSupport.hexLength(bytes, p, 4); if (len != 4) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); appendUtf8(runtime, to, code, encp, str, mode); return p + 4; }
/** * Unescape unicode BMP char at given offset, appending to the specified * buffer if non-null. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeBmp(Ruby runtime, ByteList to, byte[] bytes, int p, int end, Encoding[] encp, ByteList str, ErrorMode mode) { if (p + 4 > end) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); int code = StringSupport.scanHex(bytes, p, 4); int len = StringSupport.hexLength(bytes, p, 4); if (len != 4) raisePreprocessError(runtime, str, "invalid Unicode escape", mode); appendUtf8(runtime, to, code, encp, str, mode); return p + 4; }
/** * Unescape unicode characters at given offset, appending to the given * out buffer if provided. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeList(Ruby runtime, ByteList to, byte[]bytes, int p, int end, Encoding[]encp, ByteList str, ErrorMode mode) { while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; boolean hasUnicode = false; while (true) { int code = StringSupport.scanHex(bytes, p, end - p); int len = StringSupport.hexLength(bytes, p, end - p); if (len == 0) break; if (len > 6) raisePreprocessError(runtime, str, "invalid Unicode range", mode); p += len; if (to != null) appendUtf8(runtime, to, code, encp, str, mode); hasUnicode = true; while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; } if (!hasUnicode) raisePreprocessError(runtime, str, "invalid Unicode list", mode); return p; }
/** * Unescape unicode characters at given offset, appending to the given * out buffer if provided. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeList(Ruby runtime, ByteList to, byte[]bytes, int p, int end, Encoding[]encp, ByteList str, ErrorMode mode) { while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; boolean hasUnicode = false; while (true) { int code = StringSupport.scanHex(bytes, p, end - p); int len = StringSupport.hexLength(bytes, p, end - p); if (len == 0) break; if (len > 6) raisePreprocessError(runtime, str, "invalid Unicode range", mode); p += len; if (to != null) appendUtf8(runtime, to, code, encp, str, mode); hasUnicode = true; while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; } if (!hasUnicode) raisePreprocessError(runtime, str, "invalid Unicode list", mode); return p; }
/** * Unescape unicode characters at given offset, appending to the given * out buffer if provided. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeList(Ruby runtime, ByteList to, byte[]bytes, int p, int end, Encoding[]encp, ByteList str, ErrorMode mode) { while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; boolean hasUnicode = false; while (true) { int code = StringSupport.scanHex(bytes, p, end - p); int len = StringSupport.hexLength(bytes, p, end - p); if (len == 0) break; if (len > 6) raisePreprocessError(runtime, str, "invalid Unicode range", mode); p += len; if (to != null) appendUtf8(runtime, to, code, encp, str, mode); hasUnicode = true; while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; } if (!hasUnicode) raisePreprocessError(runtime, str, "invalid Unicode list", mode); return p; }
/** * Unescape unicode characters at given offset, appending to the given * out buffer if provided. * * @param runtime current runtime * @param to output buffer; if null, no appending will be done * @param bytes input bytes * @param p start position * @param end end position * @param encp out param for fixed encoding * @param str original bytes wrapper * @param mode error mode * @return new position after unescaping */ private static int unescapeUnicodeList(Ruby runtime, ByteList to, byte[]bytes, int p, int end, Encoding[]encp, ByteList str, ErrorMode mode) { while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; boolean hasUnicode = false; while (true) { int code = StringSupport.scanHex(bytes, p, end - p); int len = StringSupport.hexLength(bytes, p, end - p); if (len == 0) break; if (len > 6) raisePreprocessError(runtime, str, "invalid Unicode range", mode); p += len; if (to != null) appendUtf8(runtime, to, code, encp, str, mode); hasUnicode = true; while (p < end && ASCIIEncoding.INSTANCE.isSpace(bytes[p] & 0xff)) p++; } if (!hasUnicode) raisePreprocessError(runtime, str, "invalid Unicode list", mode); return p; }
int hlen = end < p + 2 ? end - p : 2; code = StringSupport.scanHex(bytes, p, hlen); int len = StringSupport.hexLength(bytes, p, hlen); if (len < 1) raisePreprocessError(runtime, str, "invalid hex escape", mode); p += len;
int hlen = end < p + 2 ? end - p : 2; code = StringSupport.scanHex(bytes, p, hlen); int len = StringSupport.hexLength(bytes, p, hlen); if (len < 1) raisePreprocessError(runtime, str, "invalid hex escape", mode); p += len;
int hlen = end < p + 2 ? end - p : 2; code = StringSupport.scanHex(bytes, p, hlen); int len = StringSupport.hexLength(bytes, p, hlen); if (len < 1) raisePreprocessError(runtime, str, "invalid hex escape", mode); p += len;
int hlen = end < p + 2 ? end - p : 2; code = StringSupport.scanHex(bytes, p, hlen); int len = StringSupport.hexLength(bytes, p, hlen); if (len < 1) raisePreprocessError(runtime, str, "invalid hex escape", mode); p += len;