当前位置: 代码迷 >> Java Web开发 >> 编码转换解决方案
  详细解决方案

编码转换解决方案

热度:11   发布时间:2016-04-17 01:21:37.0
编码转换
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");
  相关解决方案