简体   繁体   English

从NSData转换为NSString后更改了字符串信息

[英]Changed string info after conversion from NSData to NSString

I'm converting a NSData object, that is returned from AFHTTPRequestOperation, to NSString: 我正在将从AFHTTPRequestOperation返回的NSData对象转换为NSString:

NSString *responseString = [[NSString alloc] initWithData:responseObject
                             encoding:NSUTF8StringEncoding];
NSLog(@"%@", responseString);

but I realised that the information in responseObject is changed from 但我意识到responseObject中的信息已经改变了

<39306563 34636638 30353164 34303365 66346531 38643265 37393036 63333866>

to

90ec4cf8051d403ef4e18d2e7906c38f

Help me please... 请帮帮我...

There is no change of the data, they are two different representations of the same data: hexadecimal and character (ASCII). 数据没有变化,它们是相同数据的两种不同表示:十六进制和字符(ASCII)。

39306563 34636638 30353164 34303365 66346531 38643265 37393036 63333866 39306563 34636638 30353164 34303365 66346531 38643265 37393036 63333866
Is a hexadecimal representation of the data. 是数据的十六进制表示。

90ec4cf8051d403ef4e18d2e7906c38f 90ec4cf8051d403ef4e18d2e7906c38f
Is a character string representation. 是字符串表示。

They are the same data. 它们是相同的数据。

As a partial example: In the hexadecimal example each two character represents one byte as two hexadecimal digits. 作为部分示例:在十六进制示例中,每两个字符将一个字节表示为两个十六进制数字。
In the character example each character represents one byte as one character. 在字符示例中,每个字符代表一个字节作为一个字符。

hex 39 is character 9 十六进制39是字符9
hex 30 is character 0 十六进制30是字符0
hex 65 is character e 十六进制65是字符e
hex 63 is character c 十六进制63是字符c
... ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM