抓取到数据包的打印和注释如下
hex->[0]7b [1]22 [2]72 [3]65 [4]73 [5]75 [6]6c [7]74 [8]73 [9]22 [10]3a [11] 5b [12]7b [13]22 [14]6c [15]6f [16]63 [17]61 [18]74 [19]69 [20]6f [21]6e [22] 22 [23]3a [24]7b [25]22 [26]69 [27]64 [28]22 [29]3a [30]22 [31]57 [32]57 [33] 47 [34]51 [35]44 [36]43 [37]57 [38]36 [39]54 [40]42 [41]57 [42]31 [43]22 [44] 2c [45]22
[46]6e [47]61 [48]6d [49]65 -> name
[50]22 [51]3a [52]22 -> ":"
[53]e5 [54]a4 [55]a9 [56]e6 [57]b4 [58]a5 ->天津
[59]22 [60]2c [61]22 -> ","
[62]63 [63]6f [64]75 [65]6e [66]
74 [67]72 [68]79 [69]22 [70]3a [71]22 [72]43 [73]4e [74]22 [75]2c [76]22 [77] 70 [78]61 [79]74 [80]68
[81]22 [82]3a [83]22
[84]e5 [85]a4 [86]a9 [87]e6 [88]b4 [89]a5 ->天津
[90]2c [91]e5 [92]a4 [93]a9 [94]e6 [95]b4 [96]a5 ->天津
[97]2c
[98]e4 [99]b8 [100]ad [101]e5 [102]9b [103]bd -> 中国
进行UTF8转GBK的函数测试
memset(utf, 0x00, sizeof(utf));
memset(gbk, 0x00, sizeof(gbk));
memcpy(utf, "\xe5\xa4\xa9\xe6\xb4\xa5", 6);
SwitchToGbk(utf, 6, gbk , &outlen);
printbuf("switch to GBK tianjin", gbk, 10);
memset(utf, 0x00, sizeof(utf));
memset(gbk, 0x00, sizeof(gbk));
memcpy(utf, "\xe4\xb8\xad\xe5\x9b\xbd", 6);
SwitchToGbk(utf, 6, gbk , &outlen);
printbuf("switch to GBK zhongguo", gbk, 10);
打印如下
switch to GBK tianjin->[0]cc [1]ec [2]bd [3]f2 [4]00 [5]00 [6]00 [7]00 [8]00 [9]00
switch to GBK zhongguo->[0]d6 [1]d0 [2]b9 [3]fa [4]00 [5]00 [6]00 [7]00 [8]00 [9]00
经查GBK编码表,转换正常可用
GBK编码表.zip
(62.53 KB)
|