| 13 | |
| 14 | /* Print a Unicode name suitably escaped */ |
| 15 | private static void printName(String name) { |
| 16 | // Need to escape Unicode data if we find it. |
| 17 | boolean seenUnicode = false; |
| 18 | StringBuilder sb = new StringBuilder(); |
| 19 | for (int ii=0; ii<name.length(); ii++) { |
| 20 | char c = name.charAt(ii); |
| 21 | if ((c >= 32) && (c < 127)) { |
| 22 | if (c == SINGLE_QUOTE) { |
| 23 | sb.append("\\'"); |
| 24 | } else if (c == BACKSLASH) { |
| 25 | sb.append("\\\\"); |
| 26 | } else { |
| 27 | sb.append(c); |
| 28 | } |
| 29 | } else { |
| 30 | // Non-ASCII. Assume nothing outside of the BMP |
| 31 | seenUnicode = true; |
| 32 | sb.append("\\u"); |
| 33 | sb.append(hexChar[(c >> 12) & 0xF]); |
| 34 | sb.append(hexChar[(c >> 8) & 0xF]); |
| 35 | sb.append(hexChar[(c >> 4) & 0xF]); |
| 36 | sb.append(hexChar[c & 0xF]); |
| 37 | } |
| 38 | } |
| 39 | if (seenUnicode) { |
| 40 | System.out.print("u('"); |
| 41 | System.out.print(sb.toString()); |
| 42 | System.out.print("')"); |
| 43 | } else { |
| 44 | System.out.print("'"); |
| 45 | System.out.print(sb.toString()); |
| 46 | System.out.print("'"); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | private static void printProperty(String propName) { |
| 51 | String propVal = System.getProperty(propName, null); |