我有一个小资产,想嵌入字节。我获取了资产,打印出字节,然后将字节放入字节数组并将这些字节加载到字符串中。看起来像一个字节序问题。我在这里做错了什么?
字节打印机.app
const char *helloworldc = "Hello, World!";
NSString *helloworld = [NSString stringWithUTF8String:helloworldc];
NSData *data = [helloworld dataUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@", [data description]);
输出:
<48656c6c 6f2c2057 6f726c64 21>
ByteImporter.App
const uint32_t bytes[] = {0x48656c6c, 0x6f2c2057, 0x6f726c64, 0x21};
NSString *helloworld = [[NSString alloc] initWithBytes:bytes
length:sizeof(bytes)
encoding:NSUTF8StringEncoding];
NSLog(@"%@", helloworld);
输出:
lleHW ,odlro!