Here you can find the source of toAscii(String notAscii)
Parameter | Description |
---|---|
notAscii | The string to change. |
public static String toAscii(String notAscii)
//package com.java2s; //License from project: Apache License public class Main { /**/* w w w.j a v a 2s .c om*/ * Changes a non-ascii string into an HTML encoded ascii string. * * @param notAscii The string to change. * * @return The converted string. */ public static String toAscii(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 > 255) { builder.append("&#" + (int) a + ";"); } else { builder.append(a); } } return builder.toString(); } }