Friday, July 6, 2012

How to get decimal HTML entity from String in Java?



Below is the method for returning the decimal entity.........

public static String getHTMLEntity(String value) {
StringBuffer testBuffer = new StringBuffer();
char[] test = value.toCharArray();
if (test != null) {
int size1 = test.length;


for (int j = 0; j < size1; j++) {
testBuffer.append("&#");
testBuffer.append(Character.codePointAt(test, j));
testBuffer.append(";");
}
}
return testBuffer.toString();
}


OUTPUT for "सड्फलक्ल क्लजकलसदफ  क्ळज्सलड्फ"


&#2360;&#2337;&#2381;&#2347;&#2354;&#2325;&#2381;&#2354;&#32;&#2325;&#2381;&#2354;&#2332;&#2325;&#2354;&#2360;&#2342;&#2347;&#32;&#32;&#2325;&#2381;&#2355;&#2332;&#2381;&#2360;&#2354;&#2337;&#2381;&#2347;

No comments:

Post a Comment