一、前言
关于oschrenk-util源码包中com.oschrenk.utils.CharUtils字符工具类,进行字符与字符串相互转换unicodeEscaped处理、ascii编码判断isAscii等方法实现,详情参见源码说明。
二、源码说明
package com.oschrenk.utils;@b@@b@public class CharUtils@b@{@b@ public static final char LF = 10;@b@ public static final char CR = 13;@b@@b@ public static String unicodeEscaped(char ch)@b@ {@b@ if (ch < '\16')@b@ return "\\u000" + Integer.toHexString(ch);@b@ if (ch < 256)@b@ return "\\u00" + Integer.toHexString(ch);@b@ if (ch < 4096)@b@ return "\\u0" + Integer.toHexString(ch);@b@@b@ return "\\u" + Integer.toHexString(ch);@b@ }@b@@b@ public static String unicodeEscaped(Character ch)@b@ {@b@ if (ch == null)@b@ return null;@b@@b@ return unicodeEscaped(ch.charValue());@b@ }@b@@b@ public static boolean isAscii(char ch)@b@ {@b@ return (ch < 128);@b@ }@b@@b@ public static boolean isAsciiPrintable(char ch)@b@ {@b@ return ((ch >= ' ') && (ch < ''));@b@ }@b@@b@ public static boolean isAsciiControl(char ch)@b@ {@b@ return ((ch < ' ') || (ch == ''));@b@ }@b@@b@ public static boolean isAsciiAlpha(char ch)@b@ {@b@ return (((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z')));@b@ }@b@@b@ public static boolean isAsciiAlphaUpper(char ch)@b@ {@b@ return ((ch >= 'A') && (ch <= 'Z'));@b@ }@b@@b@ public static boolean isAsciiAlphaLower(char ch)@b@ {@b@ return ((ch >= 'a') && (ch <= 'z'));@b@ }@b@@b@ public static boolean isAsciiNumeric(char ch)@b@ {@b@ return ((ch >= '0') && (ch <= '9'));@b@ }@b@@b@ public static boolean isAsciiAlphanumeric(char ch)@b@ {@b@ return (((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z')) || ((ch >= '0') && (ch <= '9')));@b@ }@b@}