public static boolean restricted(XMLVersion version, int c) { return CharUtils.invset_contains( version == XMLVersion.XML10 ? RESTRICTED_SET_v1 : RESTRICTED_SET_v11, c); }
/** * Return the specified text with appropriate Unicode Control Characters given the specified Direction. * * @param direction The Directionality of the text * @param text The text to wrap within Unicode Control Characters * @return The directionally-wrapped text */ public static String getBidiText(Direction direction, String text) { switch (direction) { case LTR: return CharUtils.wrapBidi(text, CharUtils.LRE); case RTL: return CharUtils.wrapBidi(text, CharUtils.RLE); default: return text; } }
/** * Get the high surrogate of this Codepoint */ public char getHighSurrogate() { return CharUtils.getHighSurrogate(value); }
/** * Insert a codepoint into the buffer, automatically dealing with surrogate pairs */ public static void insert(CharSequence s, int i, int c) { if (!(s instanceof StringBuilder) && !(s instanceof StringBuffer)) { insert(new StringBuilder(s), i, c); } else { if (i > 0 && i < s.length()) { char ch = s.charAt(i); boolean low = isLowSurrogate(ch); if (low) { if (low && isHighSurrogate(s.charAt(i - 1))) { i--; } } } if (s instanceof StringBuffer) ((StringBuffer)s).insert(i, toString(c)); else if (s instanceof StringBuilder) ((StringBuilder)s).insert(i, toString(c)); } }
/** * Append the specified codepoint to the buffer, automatically handling surrogate pairs */ public static void append(Appendable buf, int c) { try { if (isSupplementary(c)) { buf.append(getHighSurrogate(c)); buf.append(getLowSurrogate(c)); } else buf.append((char)c); } catch (IOException e) { throw new RuntimeException(e); } }
return; int pos = 0; int lc = CharUtils.codepointAt(buf, pos).getValue(); int cpos = CharUtils.length(lc); int lcc = UnicodeCharacterDatabase.getCanonicalClass(lc); if (lcc != 0) int len = buf.length(); int c; for (int dpos = cpos; dpos < buf.length(); dpos += CharUtils.length(c)) { c = CharUtils.codepointAt(buf, dpos).getValue(); int cc = UnicodeCharacterDatabase.getCanonicalClass(c); int composite = UnicodeCharacterDatabase.getPairComposition(lc, c); if (composite != '\uFFFF' && (lcc < cc || lcc == 0)) { CharUtils.setChar(buf, pos, composite); lc = composite; } else { CharUtils.setChar(buf, cpos, c); if (buf.length() != len) { dpos += buf.length() - len; len = buf.length(); cpos += CharUtils.length(c);
private static String supplementaryToString(int c) { StringBuilder buf = new StringBuilder(); buf.append((char)getHighSurrogate(c)); buf.append((char)getLowSurrogate(c)); return buf.toString(); }
private static int findInsertionPoint(StringBuilder buf, int c) { int cc = UnicodeCharacterDatabase.getCanonicalClass(c); int i = buf.length(); if (cc != 0) { int ch; for (; i > 0; i -= CharUtils.length(c)) { ch = CharUtils.codepointAt(buf, i - 1).getValue(); if (UnicodeCharacterDatabase.getCanonicalClass(ch) <= cc) break; } } return i; }
label = Nameprep.prep(label); char[] chars = label.toCharArray(); CharUtils.verifyNot(chars, Profile.STD3ASCIIRULES); if (chars[0] == '\u002D' || chars[chars.length - 1] == '\u002D') throw new IOException("ToASCII violation"); if (!CharUtils.inRange(chars, (char)0x000, (char)0x007F)) { if (label.startsWith("xn--")) throw new IOException("ToASCII violation");
public static String prep(String s) { NameprepCodepointIterator r = null; try { StringBuilder buf = new StringBuilder(); CodepointIterator ci = CodepointIterator.forCharSequence(s); r = new NameprepCodepointIterator(ci); while (r.hasNext()) { Codepoint cp = r.next(); int i = cp != null ? cp.getValue() : -1; if (i != -1) { CharUtils.append(buf, cp); } } String n = Normalizer.normalize(buf.toString(), Normalizer.Form.KC).toString(); CharUtils.verify(CodepointIterator.forCharSequence(n), new Filter() { public boolean accept(int c) { return isProhibited(c); } }); return n; } catch (Throwable e) { return null; } }
public boolean isAlphaDigit() { return CharUtils.isAlpha(value); }
/** * Append the specified codepoint to the buffer, automatically handling surrogate pairs */ public static void append(Appendable buf, Codepoint c) { append(buf, c.getValue()); }
/** * Get the low surrogate of this Codepoint */ public char getLowSurrogate() { return CharUtils.getLowSurrogate(value); }
/** * Insert a codepoint into the buffer, automatically dealing with surrogate pairs */ public static void insert(CharSequence s, int i, Codepoint c) { insert(s, i, c.getValue()); }
/** * True if the codepoint is a digit */ public static boolean isDigit(int codepoint) { return CharUtils.inRange(codepoint, '0', '9'); }