473,796 Members | 2,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use streamreader to reader chinese newsgroup article and display it properly?

Hi all,

I am new to C# and currently writing a Nntp client to read article
from a chinese newsgroup. I am curious how to decode the chinese
character using streamreader and display it properly on Win2K and
WinXP?

I have tried the following:

// send XOVER commands to get the header XOVER 1234-1234

// read the header (subject, from, date, arthur)
Streamreader sr = new Streamreader(nn tpStream, Encoding.Defaul t); //
1
string str = sr.ReadLine();
listbox.Item.Ad d(str);

the output of 3 will shows some wierd characters. I tried changing the
encoding to UTF7/UTF8/Unicode, on both win2k and winXP, it is still
showing wierd characters.

Can anyone show me how to read and decode and display the chinese
character properly? Thanks

Kaede
Nov 16 '05 #1
3 3766

"kaede" <ka************ @hotmail.com> wrote in message
news:60******** *************** **@posting.goog le.com...
Hi all,

I am new to C# and currently writing a Nntp client to read article
from a chinese newsgroup. I am curious how to decode the chinese
character using streamreader and display it properly on Win2K and
WinXP?

I have tried the following:

// send XOVER commands to get the header XOVER 1234-1234

// read the header (subject, from, date, arthur)
Streamreader sr = new Streamreader(nn tpStream, Encoding.Defaul t); //
1
string str = sr.ReadLine();
listbox.Item.Ad d(str);

the output of 3 will shows some wierd characters. I tried changing the
encoding to UTF7/UTF8/Unicode, on both win2k and winXP, it is still
showing wierd characters.


Well, for one, you should be examining the charset returned in the
Content-Type header(assuming it is set in the message).

However, the best default would probably be a strictly Chinese encoding. I
believe Big5 is one, you'll have to look up any others.
Nov 16 '05 #2
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:<el******* *******@TK2MSFT NGP15.phx.gbl>. ..
"kaede" <ka************ @hotmail.com> wrote in message
news:60******** *************** **@posting.goog le.com...
Hi all,

I am new to C# and currently writing a Nntp client to read article
from a chinese newsgroup. I am curious how to decode the chinese
character using streamreader and display it properly on Win2K and
WinXP?

I have tried the following:

// send XOVER commands to get the header XOVER 1234-1234

// read the header (subject, from, date, arthur)
Streamreader sr = new Streamreader(nn tpStream, Encoding.Defaul t); //
1
string str = sr.ReadLine();
listbox.Item.Ad d(str);

the output of 3 will shows some wierd characters. I tried changing the
encoding to UTF7/UTF8/Unicode, on both win2k and winXP, it is still
showing wierd characters.


Well, for one, you should be examining the charset returned in the
Content-Type header(assuming it is set in the message).

However, the best default would probably be a strictly Chinese encoding. I
believe Big5 is one, you'll have to look up any others.


Do you know how do I set the encoding to Big5? Should I used
StreamReader using Encoding.Defaul t to examine the Content-Type. Then,
open another streamReader with the appropriate encoding to get the
article?

Do you know of any sample code that show me how to do that?

Thanks very much
Kaede
Nov 16 '05 #3

"kaede" <ka************ @hotmail.com> wrote in message
news:60******** *************** ***@posting.goo gle.com...
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:<el******* *******@TK2MSFT NGP15.phx.gbl>. ..
"kaede" <ka************ @hotmail.com> wrote in message
news:60******** *************** **@posting.goog le.com...
> Hi all,
>
> I am new to C# and currently writing a Nntp client to read article
> from a chinese newsgroup. I am curious how to decode the chinese
> character using streamreader and display it properly on Win2K and
> WinXP?
>
> I have tried the following:
>
> // send XOVER commands to get the header XOVER 1234-1234
>
> // read the header (subject, from, date, arthur)
> Streamreader sr = new Streamreader(nn tpStream, Encoding.Defaul t); //
> 1
> string str = sr.ReadLine();
> listbox.Item.Ad d(str);
>
> the output of 3 will shows some wierd characters. I tried changing the
> encoding to UTF7/UTF8/Unicode, on both win2k and winXP, it is still
> showing wierd characters.
Well, for one, you should be examining the charset returned in the
Content-Type header(assuming it is set in the message).

However, the best default would probably be a strictly Chinese encoding.
I
believe Big5 is one, you'll have to look up any others.


Do you know how do I set the encoding to Big5? Should I used


Encoding.GetEnc oding("Big5"); I think
StreamReader using Encoding.Defaul t to examine the Content-Type. Then,
open another streamReader with the appropriate encoding to get the
article?
That I am not sure about. I think the character set for mime headers is set,
but I really don't know for sure, -_-.

Big5, however, is likely compatible with ASCII in its lower 7 bits, much as
most other encodings are.

Do you know of any sample code that show me how to do that?

Thanks very much
Kaede

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4768
by: Jeff | last post by:
Having a problem displaying both german and chinese characters from a UTF-8 database on the same *.jsp page. Can make Chinese characters appear correctly by including the following lines: <%@ page pageEncoding="UTF-8" %> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7
4802
by: Hans | last post by:
Hi, I need to process files that are created in UTF-7 format. This works fine upto the point where a '+' character (0x2B/43) appears in the line. The string is mutilated... The reader appears to have a bug - or am I doing something wrong here??? The code: StreamReader Reader = new StreamReader
7
3966
by: BlueOysterCult | last post by:
Hello all I have a project that I have to read the file - which I have done I can see the file output. I then need to read the line - parse the line into three separate values (there are 3 = name age and gender) static void DoPartD() { FileInfo theSourceFile = new FileInfo(@"c:\\Documents and
1
2998
by: Krich | last post by:
I have text file contains word in English language and in foreign language and I include this text file as embedded resource in my project. VB.NET editor can display the foreign langue of this text file. create stream reader object to read from this file. The object can read the data in text file but it seems when I display it to
1
4930
by: foreman | last post by:
Hi there, Hello everybody. I am a newbie to dot net framework class lib. I am confused about those classes such as all of the stream classes and those XXXReader XXXWriter. In fact, I have tried the StreamReader(which can read in big5 encoding text files well) and besides, I have tried the BufferedStream to do the same thing. It does work fine except that It can't interpret the Chinese big5 words well(which becomes messy code around)....
4
10905
by: Hexman | last post by:
Code below ---- I've asked a similar question on this forum earlier. This is a slightly different situation. Previous Question ---- I'm trying to save some specific web pages to disk as text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a single URL and it worked fine. Now when I incorporate an array of URL's, it fails to work. The first "responseFromServer"...
0
2727
by: slchslch | last post by:
Hi all, I have search through multiple forum to look for the respective solution for this problem but still i do not find any solution to this problem. I have Samsung SGH-D520 on hand which is able to display the Chinese & Thai font on the phone menu's by using the pre-set system language. Using the same code in java J2ME game to display english, chinese and thai character, the result was it failed to display any single Chinese & Thai...
2
4570
by: Clive Green | last post by:
Hello peeps, I am using PHP 5.2.2 together with MP3_Id (a PEAR module for reading and writing MP3 tags). I have been using PHP on the command line (Mac OS X Unix shell, to be precise), and am getting on more or less OK. So far, I have managed to parse my tab-delimited .txt file properly into an array, and then use this array to update the tags on a bunch of MP3 audio files. Nice.
3
3256
by: =?Utf-8?B?amVmZjMxMTYy?= | last post by:
Hi all Using vs2003 and C# in a web app. I want the user to be able to upload a file. I have an htmlFileField (<input>) on my form. Then in my C# codebehind, I use fileChooseHtml.PostedFile.FileName to get the location of the file (the user chose) to read in. Then I use the following code to actually read the file: using (StreamReader sr = new StreamReader(@sFilePath))
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.