Search code examples
c#.nettextcopy-paste

binary data to and from text conversion


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#


Solution

  • 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)