How can I convert/export binary data (for example binary files like excel- or word-documents) into a string (into text format) in .NET, so that it can be imported somewhere else (e.g. in another application, which was written in another programming language (not in .NET)). Are there universal concepts to achieve this goal ?
-
You should look at Ascii85: en.wikipedia.org/wiki/Ascii85. Any such solution, however, needs support in both applications, so if you want to pass that string to another application that already exists, I would look at what that application supports.Lasse V. Karlsen– Lasse V. Karlsen2010-06-29 14:49:25 +00:00Commented Jun 29, 2010 at 14:49
-
Depending on your target client there are lot of ways to do it especially if you want to optimize as you know witch character (if any) can't be transported. But as jon said, base64 is the most common one since it is used in all mail systems (MIME also define quoted printable but for purely binary data it's notably worse than base64)Julien Roncaglia– Julien Roncaglia2010-06-29 16:00:28 +00:00Commented Jun 29, 2010 at 16:00
Add a comment
|
1 Answer
The most common form is to use Base64 encoding between binary and text. .NET supports this with Convert.ToBase64String and Convert.FromBase64String.
Base64 is widely supported, and is a common way of encoding binary data in pure ASCII, encoding 3 bytes into 4 characters (repeatedly).