如何“连接” NSString 的字节及其长度在一起?
我有一个具有一定长度 [LEN] 的 NSString [WORD]。我需要做的是从这个字符串中获取字节并将它们与短长度(2字节)放在一起,所以我会有[WORD] [LEN]。 例如 字符串“AB”在utf8十六进制中是4142。这个字符串的长度是2==>十六进制的 0002。 所以所有内容加在一起就是 41420002。如何将这些字节组合在一起?
I have a NSString [WORD] that has some length [LEN]. What i need to do is to get bytes from this string and put them together with length in short (2 bytes), so i would have [WORD] [LEN].
E.g.
String "AB" in utf8 HEX is 4142. Length of this string is 2==> 0002 in HEX.
So everything together is 41420002. How to get this bytes together?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这段代码可以满足您的要求。
希望有帮助!
I think this code does what you want.
Hope it helps!