我正在尝试解码以下对象,该变量名为data
,类型为UInt8
。
(UInt8 [520]) data = {
[0] = '\xff'
[1] = '\0'
[2] = '2'
[3] = '\0'
[4] = 'H'
[5] = '\0'
[6] = 'o'
[7] = '\0'
[8] = 's'
[9] = '\0'
[10] = 't'
[11] = '\0'
[12] = 'e'
[13] = '\0'
[14] = 'd'
[15] = '\0'
[16] = ' '
[17] = '\0'
[18] = 'o'
[19] = '\0'
[20] = 'n'
[21] = '\0'
[22] = ' '
[23] = '\0'
[24] = 'D'
[25] = '\0'
[26] = 'i'
[27] = '\0'
[28] = 'g'
[29] = '\0'
[30] = 'i'
[31] = '\0'
[32] = 't'
[33] = '\0'
[34] = 'a'
[35] = '\0'
[36] = 'l'
[37] = '\0'
[38] = ' '
[39] = '\0'
[40] = 'O'
[41] = '\0'
[42] = 'c'
[43] = '\0'
[44] = 'e'
[45] = '\0'
[46] = 'a'
[47] = '\0'
[48] = 'n'
[49] = '\0'
[50] = '.'
[51] = '\0'
[52] = ' '
[53] = '\0'
[54] = 'M'
[55] = '\0'
[56] = 'a'
[57] = '\0'
[58] = 'n'
[59] = '\0'
[60] = 'a'
[61] = '\0'
[62] = 'g'
[63] = '\0'
[64] = 'e'
[65] = '\0'
[66] = 'd'
[67] = '\0'
[68] = ' '
[69] = '\0'
[70] = 'w'
[71] = '\0'
[72] = 'i'
[73] = '\0'
[74] = 't'
[75] = '\0'
[76] = 'h'
[77] = '\0'
[78] = ' '
[79] = '\0'
[80] = 'P'
[81] = '\0'
[82] = 'u'
[83] = '\0'
[84] = 'p'
[85] = '\0'
[86] = 'p'
[87] = '\0'
[88] = 'e'
[89] = '\0'
[90] = 't'
[91] = '\0'
[92] = '!'
[93] = '\0'
[94] = '\xa7'
[95] = '\0'
[96] = '0'
[97] = '\0'
[98] = '\xa7'
[99] = '\0'
[100] = '2'
[101] = '\0'
[102] = '0'
[103] = '\0'
[104] = '\xa9'
[105] = '\x14'
[106] = '\x0e'
[107] = '\x02'
[108] = '\x01'
[109] = '\0'
[110] = '\0'
[111] = '\0'
[112] = '\xe3'
[113] = ' '
[114] = '\x0e'
[115] = '\x02'
[116] = '\x01'
[117] = '\0'
[118] = '\0'
[119] = '\0'
[120] = '\xe8'
[121] = '\xc3'
[122] = '\x85'
[123] = '\x01'
[124] = '\x01'
[125] = '\0'
[126] = '\0'
[127] = '\0'
[128] = '\0'
[129] = '\xc3'
[130] = '\x85'
[131] = '\x01'
[132] = '\x01'
[133] = '\0'
[134] = '\0'
[135] = '\0'
[136] = '\xc8'
[137] = 'P'
[138] = '\0'
[139] = '\0'
[140] = '\x01'
[141] = '\0'
[142] = '\0'
[143] = '\0'
[144] = '`'
[145] = '\xc3'
[146] = '\xbf'
[147] = '_'
[148] = '\xff'
[149] = '\x7f'
[150] = '\0'
[151] = '\0'
[152] = 'a'
[153] = '"'
[154] = '\x0e'
[155] = '\x02'
[156] = '\x01'
[157] = '\0'
[158] = '\0'
[159] = '\0'
[160] = '\xf8'
[161] = '\xc3'
[162] = '\x85'
[163] = '\x01'
[164] = '\x01'
[165] = '\0'
[166] = '\0'
[167] = '\0'
[168] = '\xfc'
[169] = '\xc3'
[170] = '\x85'
[171] = '\x01'
[172] = '\x01'
[173] = '\0'
[174] = '\0'
[175] = '\0'
[176] = '\xa0'
[177] = '>'
[178] = '\x85'
[179] = '\x01'
[180] = '\0'
[181] = '\0'
[182] = '\0'
[183] = '\0'
[184] = '\xe8'
[185] = '\xc3'
[186] = '\x85'
[187] = '\x01'
[188] = '\x01'
[189] = '\0'
[190] = '\0'
[191] = '\0'
[192] = '\xe8'
[193] = '\xc3'
[194] = '\x85'
[195] = '\x01'
[196] = '\x01'
[197] = '\0'
[198] = '\0'
[199] = '\0'
[200] = '\0'
[201] = '\xc4'
[202] = '\x85'
[203] = '\x01'
[204] = '\x01'
[205] = '\0'
[206] = '\0'
[207] = '\0'
[208] = '\0'
[209] = '\0'
[210] = '\0'
[211] = '\0'
[212] = '\0'
[213] = '\0'
[214] = '\0'
[215] = '\0'
[216] = '\x80'
[217] = '6'
[218] = 'O'
[219] = '\0'
[220] = '\0'
[221] = '\0'
[222] = '\0'
[223] = '\0'
[224] = '@'
[225] = '\0'
[226] = '\0'
[227] = '\0'
[228] = '\0'
[229] = '6'
[230] = 'O'
[231] = '\0'
[232] = '\0'
[233] = '\xc3'
[234] = '\xbf'
[235] = '_'
[236] = '\xff'
[237] = '\x7f'
[238] = '\0'
[239] = '\0'
[240] = '\xfc'
[241] = '\xc3'
[242] = '\x85'
[243] = '\x01'
[244] = '\x01'
[245] = '\0'
[246] = '\0'
[247] = '\0'
[248] = '\0'
[249] = '\xc4'
[250] = '\x85'
[251] = '\x01'
[252] = '\x01'
[253] = '\0'
[254] = '\0'
[255] = '\0'
...
}
我正在使用此代码转换为NSString
。
NSString *info =[[NSString alloc] initWithBytes:data length:sizeof(data) encoding:NSUnicodeStringEncoding];
但我只是在输出中获得外国角色和翼梢。
我做错了什么?
我只对以'\xa7'
分隔的前3个部分感兴趣。
答案 0 :(得分:0)
看起来我应该使用
NSString *info =[[NSString alloc] initWithBytes:data length:sizeof(data) encoding:NSUTF16LittleEndianStringEncoding];