且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将字符串数组转换为字节数组,然后再转换回vb.net

更新时间:2023-02-17 20:51:52

每个字符串都会转换为字节数组并返回,具体取决于您要使用的编码,因此这是由编码类完成的:https://msdn.microsoft.com/en-us/library/ system.text.encoding%28v = vs.110%29.aspx [ ^ ]。



显然,因为字符串总是Unicode字符串,只有在使用代表Unicode UTF的编码时才能保证往返。对于字符串数组,您可以编码字符串之间的边界...您喜欢的任何方式。如果你向我解释你的目的,我会建议更确定的。例如,它可以是XML标记,或其他任何东西。



-SA
Each string is converted to array of bytes and back depending on the encoding you want to use, so this is done by the encoding classes: https://msdn.microsoft.com/en-us/library/system.text.encoding%28v=vs.110%29.aspx[^].

Apparently, as strings are always Unicode strings, the round trip is guaranteed in all cases only if you use encodings representing Unicode UTFs. As to the array of strings, you can encode the boundaries between strings… any way you prefer. I would advise something more certain if you explained me your purpose. For example, it could be XML markup, or anything else.

—SA