PC Review


Reply
Thread Tools Rate Thread

How to covert to UTF8

 
 
ad
Guest
Posts: n/a
 
      24th Jun 2006
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?


 
Reply With Quote
 
 
 
 
Mihai N.
Guest
Posts: n/a
 
      25th Jun 2006
> 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
 
Reply With Quote
 
ad
Guest
Posts: n/a
 
      25th Jun 2006

>> 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.



 
Reply With Quote
 
Mihai N.
Guest
Posts: n/a
 
      26th Jun 2006
> 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
 
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
tis-620 to UTF8 =?Utf-8?B?amRjaGFyYm9ubmVhdQ==?= Microsoft Dot NET 2 13th Jun 2007 06:18 AM
VT-UTF8 hyperterminal under XP? behrooz Windows XP General 4 20th Nov 2005 06:19 AM
enable utf8 =?Utf-8?B?amFl?= Microsoft Windows 2000 1 27th Jan 2005 09:40 PM
UTF8 =?Utf-8?B?amVhbg==?= Windows XP New Users 1 29th Jun 2004 10:45 PM
UTF8 Amman Microsoft C# .NET 1 11th Dec 2003 09:04 PM


Features
 

Advertising
 

Newsgroups
 


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