请问如何实现String与Unicode间的相互转换!

ajinjin 2001-06-07 12:52:00
...全文
475 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
newroc 2001-06-25
  • 打赏
  • 举报
回复
asper(天使之翼) 请教 你上面的方法是string to unicode 的,那么如何把unicode还原回来呢
asper 2001-06-08
  • 打赏
  • 举报
回复
1、用管理功能或者回复后都可以给分,呵呵
2、是这样的
ajinjin 2001-06-08
  • 打赏
  • 举报
回复
给不了分,怎么回事?
asper(天使之翼) 
是每个汉字都可以用特定的Unicode表示?;)
ajinjin 2001-06-07
  • 打赏
  • 举报
回复
并请解释下Unicode,小弟多谢了!;)
asper 2001-06-07
  • 打赏
  • 举报
回复
http://www.jguru.com/faq/view.jsp?EID=137049
这儿还有
asper 2001-06-07
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/topic/85/85236.shtm

//string to unicode
public class stou{

static public String byteToHex(byte b) {
// Returns hex String representation of byte b
char hexDigit[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };
return new String(array);
}
static public String charToHex(char c) {
// Returns hex String representation of char c
byte hi = (byte) (c >>> 8);
byte lo = (byte) (c & 0xff);
return byteToHex(hi) + byteToHex(lo);
}
public static void main(String argsv[]) {
String scource="他";
String str = charToHex(scource.charAt(0));
System.out.println(str);
System.out.println("\u4ed6");

}
} // class
字符串可以循环

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧