这种编码转换VB怎么写???
人人分享数据里的一段
{"action":"add","auth":99,"link":"http://www.56.com/u62/v_Njg4OTE4MTk.html","type":"10","shareId":"13313417524","shareid":"13313417524","shareUserId":"419819062","shareowner":"419819062","title":"职来职往选手李佳霖惹全场洒泪——很庆幸他遇到了好主持人,很庆幸他没有去非你莫属。","pic":"http://img.v157.56.com/images/21/16/love562012i56olo56i56.com_sc_133888251541hd.jpg?j=49640","fromno":"0","fromname":"","fromuniv":"","fromShareId":"13313417524","fromShareOwner":"419819062","albumid":"0","currenUserTinyurl":"http://head.xiaonei.com/photos/0/0/men_tiny.gif","preForwardComment":"//范忠敏:分享视频","forwardComment":"//范忠敏:分享视频","summary":"4号李佳霖-职来职往120602","noteId":"0","body":"","sendcomment":false}
这个是可阅读数据,下面是转换后的数据
post=%7B%22action%22%3A%22add%22%2C%22auth%22%3A99%2C%22link%22%3A%22http%3A%2F%2Fwww.56.com%2Fu62%2Fv_Njg4OTE4MTk.html%22%2C%22type%22%3A%2210%22%2C%22shareId%22%3A%2213313417524%22%2C%22shareid%22%3A%2213313417524%22%2C%22shareUserId%22%3A%22419819062%22%2C%22shareowner%22%3A%22419819062%22%2C%22title%22%3A%22%E8%81%8C%E6%9D%A5%E8%81%8C%E5%BE%80%E9%80%89%E6%89%8B%E6%9D%8E%E4%BD%B3%E9%9C%96%E6%83%B9%E5%85%A8%E5%9C%BA%E6%B4%92%E6%B3%AA%E2%80%94%E2%80%94%E5%BE%88%E5%BA%86%E5%B9%B8%E4%BB%96%E9%81%87%E5%88%B0%E4%BA%86%E5%A5%BD%E4%B8%BB%E6%8C%81%E4%BA%BA%EF%BC%8C%E5%BE%88%E5%BA%86%E5%B9%B8%E4%BB%96%E6%B2%A1%E6%9C%89%E5%8E%BB%E9%9D%9E%E4%BD%A0%E8%8E%AB%E5%B1%9E%E3%80%82%22%2C%22pic%22%3A%22http%3A%2F%2Fimg.v157.56.com%2Fimages%2F21%2F16%2Flove562012i56olo56i56.com_sc_133888251541hd.jpg%3Fj%3D49640%22%2C%22fromno%22%3A%220%22%2C%22fromname%22%3A%22%22%2C%22fromuniv%22%3A%22%22%2C%22fromShareId%22%3A%2213313417524%22%2C%22fromShareOwner%22%3A%22419819062%22%2C%22albumid%22%3A%220%22%2C%22currenUserTinyurl%22%3A%22http%3A%2F%2Fhead.xiaonei.com%2Fphotos%2F0%2F0%2Fmen_tiny.gif%22%2C%22preForwardComment%22%3A%22%2F%2F%E8%8C%83%E5%BF%A0%E6%95%8F%3A%E5%88%86%E4%BA%AB%E8%A7%86%E9%A2%91%22%2C%22forwardComment%22%3A%22%2F%2F%E8%8C%83%E5%BF%A0%E6%95%8F%3A%E5%88%86%E4%BA%AB%E8%A7%86%E9%A2%91%22%2C%22summary%22%3A%224%E5%8F%B7%E6%9D%8E%E4%BD%B3%E9%9C%96-%E8%81%8C%E6%9D%A5%E8%81%8C%E5%BE%80120602%22%2C%22noteId%22%3A%220%22%2C%22body%22%3A%22%22%2C%22sendcomment%22%3Afalse%7D&requestToken=-18954213&_rtk=ca9fc675
其实就是utf版的URLDecode/URLencode,可是百度网上的那些代码全是错的,没一个对的!到底应该怎么写,要2个互相都能转换的
[解决办法]
仅供参考
Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As LongPrivate Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long'常用的代码页:const cpUTF8 =65001const cpGB2312 = 936const cpGB18030=54936const cpUTF7 =65000Function MultiByteToUTF16(UTF8() As Byte, CodePage As Long) As String Dim bufSize As Long bufSize = MultiByteToWideChar(CodePage, 0&, UTF8(0), UBound(UTF8) + 1, 0, 0) MultiByteToUTF16 = Space(bufSize) MultiByteToWideChar CodePage, 0&, UTF8(0), UBound(UTF8) + 1, StrPtr(MultiByteToUTF16), bufSizeEnd FunctionFunction UTF16ToMultiByte(UTF16 As String, CodePage As Long) As Byte() Dim bufSize As Long Dim arr() As Byte bufSize = WideCharToMultiByte(CodePage, 0&, StrPtr(UTF16), Len(UTF16), 0, 0, 0, 0) ReDim arr(bufSize - 1) WideCharToMultiByte CodePage, 0&, StrPtr(UTF16), Len(UTF16), arr(0), bufSize, 0, 0 UTF16ToMultiByte = arrEnd FunctionPrivate Sub Command1_Click() MsgBox MultiByteToUTF16(UTF16ToMultiByte("ab中,c", cpUTF8), cpUTF8)End Sub