By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,965 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,965 IT Pros & Developers. It's quick & easy.

How to convert UTF8 data to a ASCII data?

P: n/a
I read the content from a file encoded with UTF8 like this:
byte[] data = binaryReader.ReadBytes(file.Length);

And next step, I want to transform data to ASCII format, How can I do
this?
You know, Using Encoding.UTF8.GetString(data) can get a ASCII string,
but I need a byte[].
I hope you get my point. Any suggestion will be appreciated.

Jan 5 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
try

using System.Text;

ASCIIEncoding ascii = new ASCIIEncoding();
UTF8Encoding utf8 = new UTF8Encoding();

byte[] asciiBytes = Encoding.Convert(utf8, ascii, utf8bytes);

Jan 5 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.