Agreed, I just picked the first encoding on the list
When dealing with binary data, wouldn't using UTF8 (or any other MBCS, for
that matter) be a bad idea too? At the worst case it would waste a lot of
space, since two bytes (or more, depending on the MBCS binary encoding)
would be used for each byte worth of data? As I understand it (and I could
very well be wrong, since it's been a long time sonce I have sotred binary
data in a character data type ;-) ) , the best character set for doing this
is ISO8859P1 since theoretically it holds the 127 ASCII values plus the 128
"high ASCII" characters? Anyway, if it did, it'd be cool since each
character/byte would end up taking a single byte's worth of space after
conversion...
Gabriel Magaña said:
If what you are asking is how to store binary data in a text DB field, you
should not do that, as you will get into trouble when you start converting
bytes to chars and vice versa...
If you are sure this is what you want to do, though, the answer depends on
what datatype the DB field is... Since you specified "FullName" as the
field name, I'll assume it;s a varchar or other text field... In this
case
use the Enconding functions, such as:
Encoding.ASCII.GetBytes(row["FullName"].ToString());
To do the opposite use the GetChars() function.
Be warned, though, if you are not saving text characters make absolutely
sure that whatever encoding you choose can save (and give you back) the
byte
value ranges you need to store and retrieve.
Note that choosing Encoding.ASCII is almost always a bad idea, unless
you're absolutely *positive* that there won't be any characters above
Unicode 127. I would suggest using Encoding.UTF8 usually.