PC Review


Reply
Thread Tools Rate Thread

How to convert UTF8 data to a ASCII data?

 
 
Hooyoo
Guest
Posts: n/a
 
      5th Jan 2007
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.

 
Reply With Quote
 
 
 
 
Arthur
Guest
Posts: n/a
 
      5th Jan 2007
try

using System.Text;

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

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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Binary Data to ASCII as400tips@lycos.com Microsoft C# .NET 6 12th Sep 2006 11:45 PM
String of UTF8 data to byte(), HOW?? Søren M. Olesen Microsoft VB .NET 1 11th Oct 2004 04:04 PM
UTF8/UTF7/ASCII problem while reading from text file Lenard Gunda Microsoft C# .NET 5 7th Aug 2004 06:12 PM
Convert hex data to ASCII decimal string format Tom Shelton Microsoft VB .NET 4 30th May 2004 08:29 PM
Converting UTF8 -> ASCII C# Learner Microsoft Dot NET Framework 3 21st Jan 2004 07:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:23 AM.