CharUtil { public static int toAscii(char ch) { if (ch <= 0xFF) { return ch; } return 0x3F; }  static int toAscii(char ch); static boolean isWhitespace(char ch); static Character toCharacterObject(char ch); static Character toCharacterObject(String str); static char toChar(byte b); static char toChar(Character ch); static char toChar(Character ch, char defaultValue); static char toChar(String str); static char toChar(String str, char defaultValue); static int toIntValue(char ch); static int toIntValue(char ch, int defaultValue); static int toIntValue(Character ch); static int toIntValue(Character ch, int defaultValue); static String toString(char ch); static String toString(Character ch); static String unicodeEscaped(char ch); static String unicodeEscaped(Character ch); static byte[] toSimpleByteArray(char[] carr); static byte[] toSimpleByteArray(CharSequence charSequence); static char[] toSimpleCharArray(byte[] barr); static byte[] toAsciiByteArray(char[] carr); static byte[] toAsciiByteArray(CharSequence charSequence); static byte[] toRawByteArray(char[] carr); static char[] toRawCharArray(byte[] barr); static byte[] toByteArray(char[] carr); static byte[] toByteArray(char[] carr, String charset); static char[] toCharArray(byte[] barr); static char[] toCharArray(byte[] barr, String charset); static boolean equalsOne(char c, char[] match); static int findFirstEqual(char[] source, int index, char[] match); static int findFirstEqual(char[] source, int index, char match); static int findFirstDiff(char[] source, int index, char[] match); static int findFirstDiff(char[] source, int index, char match); static boolean isLowercaseLetter(char c); static boolean isUppercaseLetter(char c); static boolean isLetter(char c); static boolean isDigit(char c); static boolean isLetterOrDigit(char c); static boolean isWordChar(char c); static boolean isPropertyNameChar(char c); static boolean isAscii(char ch); static boolean isAsciiPrintable(char ch); static boolean isAsciiControl(char ch); static boolean isChinese(char c); static char toUpperAscii(char c); static char toLowerAscii(char c);  }
@Test public void toAscii() { assertEquals(0x3F, CharUtil.toAscii('你')); assertEquals(0x3F, CharUtil.toAscii('我')); assertEquals(48, CharUtil.toAscii('0')); assertEquals(9, CharUtil.toAscii('9') - CharUtil.toAscii('0')); }