Java tutorial
//package com.java2s; public class Main { /** * Changes extend ASCII and non ASCII into HTML encoded ascii string. * @param notAscii the string to change * @return the converted string */ public static String toExtendedAscii(String notAscii) { StringBuilder builder = new StringBuilder(); char[] charArray = notAscii.toCharArray(); for (int i = 0; i < charArray.length; ++i) { char a = charArray[i]; if ((int) a > 127) { builder.append("&#" + (int) a + ";"); } else { builder.append(a); } } return builder.toString(); } }