List of usage examples for java.lang Character isLowSurrogate
public static boolean isLowSurrogate(char ch)
From source file:it.geosdi.era.server.servlet.HTTPProxy.java
public static int escapeHtmlFull(int ch) { if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9') { // safe//from ww w .j a v a 2s .c o m return ch; } else if (Character.isWhitespace(ch)) { if (ch != '\n' && ch != '\r' && ch != '\t') // safe return ch; } else if (Character.isDefined(ch)) { // safe return ch; } else if (Character.isISOControl(ch)) { // paranoid version:isISOControl which are not isWhitespace // removed ! // do nothing do not include in output ! return -1; } else if (Character.isHighSurrogate((char) ch)) { // do nothing do not include in output ! return -1; } else if (Character.isLowSurrogate((char) ch)) { // wrong char[] sequence, //TODO: LOG !!! return -1; } return -1; }
From source file:adept.io.Reader.java
/** * Removes surrogate pairs//from w ww .j av a 2 s.c om * * @param text * @return */ public static String checkSurrogates(String text) { StringBuffer buffer = new StringBuffer(); char[] chars = text.toCharArray(); for (Character c : chars) { if (Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) { System.out.println("WARNING -- invalid xml character " + c + " removed"); } else { buffer.append(c); } } return buffer.toString(); }