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

How to covert to UTF8

P: n/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?
Jun 24 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> 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.
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jun 25 '06 #2

P: n/a
ad
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

Hi,

How can I use " Encoding enc_in( 950 ) "

Could you give me an example.

Jun 25 '06 #3

P: n/a
> 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();

--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jun 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.