How to covert to UTF8

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I use a fileUpload of ASP.NET to read a csv file from client into a Strem
like:
Stream myStream = FileUpload1.FileContent;

But the file from Client if of CharSet BIG5.

How can I covert it to UTF8?
 
I use a fileUpload of ASP.NET to read a csv file from client into a Strem
like:
Stream myStream = FileUpload1.FileContent;

But the file from Client if of CharSet BIG5.

How can I covert it to UTF8?
Create encoding for Big5:
Encoding enc_in( 950 );
and use it with a StreamReader

For output use Encoding.UTF8 for the StreamWriter.
 
Create encoding for Big5:
Encoding enc_in( 950 );
and use it with a StreamReader


Hi,

How can I use " Encoding enc_in( 950 ) "

Could you give me an example.
 
How can I use " Encoding enc_in( 950 ) "
Could you give me an example.

Encoding enci = Encoding.GetEncoding( 950 );
Encoding enco = Encoding.UTF8;

FileStream fsi = new FileStream("InFile", FileMode.Open, FileAccess.Read);
BufferedStream bsi = new BufferedStream(fsi);
StreamReader swi = new StreamReader(bsi, enci);

FileStream fso = new FileStream("OutFile", FileMode.Create,
FileAccess.Write);
BufferedStream bso = new BufferedStream(fso);
StreamWriter swo = new StreamWriter(bso, enco);

string buffer;
do {
buffer = swi.ReadLine();
if( buffer != null )
swo.WriteLine( buffer );
} while( buffer != null );

swo.Close();
swi.Close();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top