Is there a standard technique for packing binary data into a UTF-16 string?
问题 (In .NET) I have arbitrary binary data stored in in a byte[] (an image, for example). Now, I need to store that data in a string (a "Comment" field of a legacy API). Is there a standard technique for packing this binary data into a string ? By "packing" I mean that for any reasonably large and random data set, bytes.Length/2 is about the same as packed.Length ; because two bytes are more-or-less a single character. The two "obvious" answers don't meet all the criteria: string base64 = System