views:

85

answers:

3

Sometimes i generate data that is as little as 1k. I thought it may be good if i could convert it to text so i can paste it to someone on a forum or on MSN. How can i convert data into text then convert back? How many bits can i use? I must have it compatible with pasting on forums and i would like it to be compatible with msn if the string isnt to long. How can i make the data text safe?

Should i assume the data is only allowed to be 6bits? Is 32-127 the only values available? will i have a problem copy/pasting 127 (ascii for 'DEL'). I am using C#

+1  A: 

I think the simplest thing would be to use base64 encoding. It will take any binary data and convert it to text suitable for pasting anywhere.

In C# you can use Convert.ToBase64String (or something like this)

rslite
A: 

Does your forum allow file attachments? If so just attach the binary file.

AdamRalph
+2  A: 

For safe copy and paste, consider UUEncoding or Base64Encoding. .NET has support for Base64 on the Convert class.

Finding sample code in C# that implements UUEncoding or Base64Encoding isn't too hard:

http://geekswithblogs.net/kobush/articles/63486.aspx

http://arcanecode.com/2007/03/21/encoding-strings-to-base64-in-c/

Barry Kelly