- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
public static String forHTML(String aText){
final StringBuilder result = new StringBuilder();
final StringCharacterIterator iterator = new StringCharacterIterator(aText);
char character = iterator.current();
while (character != CharacterIterator.DONE ){
if (character == '<') {
result.append("<");
}
else if (character == '>') {
result.append(">");
}
else if (character == '&') {
result.append("&");
}
else if (character == '\"') {
result.append(""");
}
else if (character == '\t') {
addCharEntity(9, result);
}
else if (character == '!') {
addCharEntity(33, result);
}
else if (character == '#') {
addCharEntity(35, result);
}
else if (character == '$') {
addCharEntity(36, result);
}
........................................
else if (character == '|') {
addCharEntity(124, result);
}
else if (character == '}') {
addCharEntity(125, result);
}
else if (character == '~') {
addCharEntity(126, result);
}
else {
//the char is not a special one
//add it to the result as is
result.append(character);
}
character = iterator.next();
}
return result.toString();
}
Escape special characters for wiseguys.
http://www.javapractices.com/topic/TopicAction.do?Id=96
macGovno 15.07.2011 13:43 # +1
guest 15.07.2011 14:24 # −5
Lure Of Chaos 15.07.2011 17:25 # +1
prevratnic 15.07.2011 18:40 # 0
просто не красиво
3.14159265 18.07.2011 13:07 # +2
просто национальность.
prevratnic 18.07.2011 14:36 # −3
bugmenot 18.07.2011 15:26 # −2
а так Индия - полный аналог сбросивший русское колониальное Киргизии или Таджикии
absolut 18.07.2011 17:22 # −2