471,355 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

Problems using Enconding.UTF8.GetString(byte[]), values above 127 == ""

Like the subject said. I have an byte array and want to save them in a
text file with UTF8 encoding. However when an element in the byte array
is above 127 the GetString method ignores the value and I get an
incorrect string.

Anyone who knows what the problem is?

Jan 30 '06 #1
1 3374
PrettySne...@gmail.com wrote:
Like the subject said. I have an byte array and want to save them in a
text file with UTF8 encoding. However when an element in the byte array
is above 127 the GetString method ignores the value and I get an
incorrect string.

Anyone who knows what the problem is?


Yes - you're trying to treat arbitrary binary data as if it were a
valid UTF8 string, which it's not. To save binary data in a text file,
you're best to use something like Base64. See Convert.ToBase64String
and Convert.FromBase64String.

Jon

Jan 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Pablo Gutierrez | last post: by
3 posts views Thread by Kevin Pedersen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.