当前位置: 技术问答>java相关
▲高分求解▲:Unicode ——>> GB2312
来源: 互联网 发布时间:2015-05-08
本文导语: 例如: 把Unicode码串: "u4E0Du8981u8FB9u6846uFF0Cu53EAu52A0u4E0Bu5212u7EBF" 转换为其真正代表的中文字符串: "不要边框,只加下划线" 详细参考: http://www.csdn.net/expert/topic/338/338638.xml?temp=.8454553 解决马上散分。 | ...
例如:
把Unicode码串:
"u4E0Du8981u8FB9u6846uFF0Cu53EAu52A0u4E0Bu5212u7EBF"
转换为其真正代表的中文字符串:
"不要边框,只加下划线"
详细参考:
http://www.csdn.net/expert/topic/338/338638.xml?temp=.8454553
解决马上散分。
把Unicode码串:
"u4E0Du8981u8FB9u6846uFF0Cu53EAu52A0u4E0Bu5212u7EBF"
转换为其真正代表的中文字符串:
"不要边框,只加下划线"
详细参考:
http://www.csdn.net/expert/topic/338/338638.xml?temp=.8454553
解决马上散分。
|
我再帮你提一下,干嘛学我说话:)那个需求是我说的。
|
自己写一个吧:
InputStreamReader isr = new InputStreamReader( System.in );
BufferedReader br = new BufferedReader( isr );
String s = br.readLine();
StringTokenizer st = new StringTokenizer( s, "\u", false );
StringBuffer sb = new StringBuffer( st.countTokens() );
while( st.hasMoreTokens() )
sb.append( (char)Integer.parseInt(st.nextToken(), 16) );
System.out.println( sb.toString() );
InputStreamReader isr = new InputStreamReader( System.in );
BufferedReader br = new BufferedReader( isr );
String s = br.readLine();
StringTokenizer st = new StringTokenizer( s, "\u", false );
StringBuffer sb = new StringBuffer( st.countTokens() );
while( st.hasMoreTokens() )
sb.append( (char)Integer.parseInt(st.nextToken(), 16) );
System.out.println( sb.toString() );
|
String unicodeString =
"u4E0Du8981u8FB9u6846uFF0Cu53EAu52A0u4E0Bu5212u7EBF";
nativeString = unicodeString.getBytes();
try {
String str = new String(nativeString, 0, nativeString.length, "GB2312");
System.out.println(str);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
"u4E0Du8981u8FB9u6846uFF0Cu53EAu52A0u4E0Bu5212u7EBF";
nativeString = unicodeString.getBytes();
try {
String str = new String(nativeString, 0, nativeString.length, "GB2312");
System.out.println(str);
}
catch (Exception e) {
System.out.println(e.getMessage());
}