我写了一个看看用不用的着
public class UnicodeString
{
String my;
public UnicodeString(String me) {
my = new String(me);
}
public UnicodeString() {
my = null;
}
public void setUnicodeString(String me) {
my = new String(me);
}
public static String getUnicodeOf(String me) {
if (me == null)
return null;
StringBuffer tr = new StringBuffer();
String str = new String(me);
for (int i = 0; i < str.length(); i++) {
int tmp = str.charAt(i);
if (tmp < 0x100) {
tr.append(str.charAt(i));
} else {
tr.append("&#x");
tr.append(Integer.toHexString(str.charAt(i)));
tr.append(";");
}
}
return new String(tr);
}
public String getUnicodeOfMe() {
if (my == null)
return null;
StringBuffer tr = new StringBuffer();
for (int i = 0; i < my.length(); i++) {
int tmp = my.charAt(i);
if (tmp < 0x100) {
tr.append(my.charAt(i));
} else {
tr.append("&#x");
tr.append(Integer.toHexString(my.charAt(i)));
tr.append(";");
}
}
return new String(tr);
}
public static void main(String args[]) {
if (args.length < 1) {
System.out.println("usage: java UnicodeString [option] obj");
System.exit(0);
}
String t = new String(UnicodeString.getUnicodeOf(args[0]));
System.out.print(t);
}
}