二.程序深度分析
返回实际json数据:
[{"memberName":"朱成辉","sexName":"男","idCardNo":"431124199109243419","education":"大专","companyName":"aaa","telephone":"","address":"湖南省道县新车乡新车村3组","zoneName":"湖南省长沙市市辖区","driversType":"C1","newLicenseDate":"2013-08-14","licenseStartDate":"2013-08-14","licenseDuring":"6年","certificateID":"4301000100014000101","certificateType":"客运驾驶员","newCertificateDate":"2013-08-14","certificateBeginDate":"2014-02-20","certificateEndDate":"2020-02-23","faceImage":null}]
TByteArray(实际上就是c++里的无符号char 数组)数组接受的数据:
(91, 123, 34, 109, 101, 109, 98, 101, 114, 78, 97, 109, 101, 34,58, 34, 230, 156, 177, 230, 136, 144, 232, 190, 137, 34, 44, 34,115, 101, 120, 78, 97, 109, 101, 34, 58, 34, 231, 148, 183, 34, 44,34, 105, 100, 67, 97, 114, 100, 78, 111, 34, 58, 34, 52, 51, 49,49, 50, 52, 49, 57, 57, 49, 48, 57, 50, 52, 51, 52, 49, 57, 34, 44,34, 101, 100, 117, 99, 97, 116, 105, 111, 110, 34, 58, 34, 229,164, 167, 228, 184, 147, 34, 44, 34, 99, 111, 109, 112, 97, 110,121, 78, 97, 109, 101, 34, 58, 34, 97, 97, 97, 34, 44, 34, 116,101, 108, 101, 112, 104, 111, 110, 101, 34, 58, 34, 34, 44, 34, 97,100, 100, 114, 101, 115, 115, 34, 58, 34, 230, 185, 150, 229, 141,151, 231, 156, 129, 233, 129, 147, 229, 142, 191, 230, 150, 176,232, 189, 166, 228, 185, 161, 230, 150, 176, 232, 189, 166, 230,157, 145, 51, 231, 187, 132, 34, 44, 34, 122, 111, 110, 101, 78,97, 109, 101, 34, 58, 34, 230, 185, 150, 229, 141, 151, 231, 156,129, 233, 149, 191, 230, 178, 153, 229, 184, 130, 229, 184, 130,232, 190, 150, 229, 140, 186, 34, 44, 34, 100, 114, 105, 118, 101,114, 115, 84, 121, 112, 101, 34, 58, 34, 67, 49, 34, 44, 34, 110,101, 119, 76, 105, 99, 101, 110, 115, 101, 68, 97, 116, 101, 34,58, 34, 50, 48, 49, 51, 45, 48, 56, 45, 49, 52, 34, 44, 34, 108,105, 99, 101, 110, 115, 101, 83, 116, 97, 114, 116, 68, 97, 116,101, 34, 58, 34, 50, 48, 49, 51, 45, 48, 56, 45, 49, 52, 34, 44,34, 108, 105, 99, 101, 110, 115, 101, 68, 117, 114, 105, 110, 103,34, 58, 34, 54, 229, 185, 180, 34, 44, 34, 99, 101, 114, 116, 105,102, 105, 99, 97, 116, 101, 73, 68, 34, 58, 34, 52, 51, 48, 49, 48,48, 48, 49, 48, 48, 48, 49, 52, 48, 48, 48, 49, 48, 49, 34, 44, 34,99, 101, 114, 116, 105, 102, 105, 99, 97, 116, 101, 84, 121, 112,101, 34, 58, 34, 229, 174, 162, 232, 191, 144, 233, 169, 190, 233,169, 182, 229, 145, 152, 34, 44, 34, 110, 101, 119, 67, 101, 114,116, 105, 102, 105, 99, 97, 116, 101, 68, 97, 116, 101, 34, 58, 34,50, 48, 49, 51, 45, 48, 56, 45, 49, 52, 34, 44, 34, 99, 101, 114,116, 105, 102, 105, 99, 97, 116, 101, 66, 101, 103, 105, 110,...)
上面传来是utf8格式数组(通过查询第一个汉字朱的ut8编码可知 230, 156, 177,十六进制即E69CB1)
那么为什么返回的数据一定要用AnsiString接受呢,无意中看到了一篇文章http://hi.baidu.com/whmtorrent/item/bd7073db261171836cce3f1f
它最后说
"值得注意的是,UTF8编码的字符串一般要将其保存在CHAR(char)型数组里,而不保存在WCHAR(wchar_t)型数组里。为什么呢?因为UTF8编码的字符串每个字符占1-4个字节,有的字符只占1个字节,应该用CHAR型数组来保存。而WCHAR的话,一个WCHAR就占两个字节,对于只需要一个字节的字符,就会出问题。"
我想这也许就是正确答案
关于utf8的文章看http://blog.sina.com.cn/s/blog_9e2e84050102uwhv.html
联系客服