Java tutorial
//package com.java2s; public class Main { public static String checkXMLSting(String origStr) { byte[] origBytes = origStr.getBytes(); StringBuffer sb = new StringBuffer(origBytes.length); for (int i = 0; i < origBytes.length; i++) { System.out.println(i + " =" + String.valueOf(origBytes[i])); if (origBytes[i] < 0) sb.append(" "); else sb.append(origStr.substring(i, i + 1)); } return sb.toString(); } }