Browse files

Escape using commons-lang3 entity arrays

  • Loading branch information...
1 parent c81508d commit 627abf90c709bec7fa2fcfaddcfbc9d38d3ff29b @ghosthack ghosthack committed Jan 14, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/main/java/com/flaptor/indextank/util/CharacterTranslator.java
View
10 src/main/java/com/flaptor/indextank/util/CharacterTranslator.java
@@ -43,7 +43,15 @@ public void escape(StringBuilder output, String input, int start, int offset) {
for (int i = start; i < offset; i++) {
Character c = input.charAt(i);
CharSequence seq = lookupMap.get(c);
- output.append((seq == null)? c: seq);
+ if (seq != null) {
+ output.append(seq);
+ } else if (c > 0x7F) {
+ output.append("&#");
+ output.append(Integer.toString(c, 10));
+ output.append(';');
+ } else {
+ output.append(c);
+ }
}
}

0 comments on commit 627abf9

Please sign in to comment.