- VB code
Function Chr2Unicode(byval str) Dim st, t, i,t1 For i = 1 To Len(str) t = Hex(AscW(Mid(str, i, 1))) If (Len(t) < 4) Then while (Len(t) < 4) t = "0"&t Wend End If t = Mid(t, 3) & Left(t, 2) t1=mid(t,3,2)&mid(t,1,2) st = st & t1 Next Chr2Unicode = LCase(st)End Function
以上的代码是VB转换编码的函数,把字符串转换成Unicode
在Java中,像这种方法该怎么写?
在Java中有一个方法 "字符串".getBytes("Unicode");
但是我不能用这种方式,
------解决方案--------------------
new String("字符串".getBytes(), "UTF-8");