Connecting Tech Pros Worldwide Forums | Help | Site Map

StreamReader problem in reading BIG-5 file

James Wong
Guest
 
Posts: n/a
#1: Nov 20 '05
Dear all,

I'm using StreamReader to read a text file containing BIG-5 data and found
that no matter which encoding method in StreamReader's construction
parameter, the BIG-5 contents become garbage under ReadLine method. Does
anybody have any idea on this issue?

Thanks for your attention and kindly help!

Regards,
James Wong



Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#2: Nov 20 '05

re: StreamReader problem in reading BIG-5 file


James,
Are you saying that StreamReader.ReadLine itself is having problems, where
as StreamReader.Read is not having a problem?

Or that you are simply having problems reading a BIG-5 encoded file?

I don't have any BIG-5 data files to actually test this, however have you
tried something like:

Dim big5 As System.Text.Encoding =
System.Text.Encoding.GetEncoding("BIG5")

Dim input As New StreamReader("mybig5.txt", big5)
Dim line As String = input.ReadLine()
Do Until line Is Nothing
' process the line here
line = input.ReadLine()
Loop
input.Close()

For information on Unicode and Encoding in .NET see:

http://www.yoda.arachsys.com/csharp/unicode.html

Hope this helps
Jay

"James Wong" <cp_msdn@commercialpress.com.hk.NO_SPAM> wrote in message
news:eWU9oTSdEHA.3132@TK2MSFTNGP11.phx.gbl...[color=blue]
> Dear all,
>
> I'm using StreamReader to read a text file containing BIG-5 data and found
> that no matter which encoding method in StreamReader's construction
> parameter, the BIG-5 contents become garbage under ReadLine method. Does
> anybody have any idea on this issue?
>
> Thanks for your attention and kindly help!
>
> Regards,
> James Wong
>
>[/color]


James Wong
Guest
 
Posts: n/a
#3: Nov 20 '05

re: StreamReader problem in reading BIG-5 file


Hi! Jay,

Thanks for your reply and it works! My original problem occurrs in all
BIG-5 encoded file in using StreamReader.

Regards,
James

"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> ¦b¶l¥ó
news:OcSFQvSdEHA.3016@tk2msftngp13.phx.gbl ¤¤¼¶¼g...[color=blue]
> James,
> Are you saying that StreamReader.ReadLine itself is having problems, where
> as StreamReader.Read is not having a problem?
>
> Or that you are simply having problems reading a BIG-5 encoded file?
>
> I don't have any BIG-5 data files to actually test this, however have you
> tried something like:
>
> Dim big5 As System.Text.Encoding =
> System.Text.Encoding.GetEncoding("BIG5")
>
> Dim input As New StreamReader("mybig5.txt", big5)
> Dim line As String = input.ReadLine()
> Do Until line Is Nothing
> ' process the line here
> line = input.ReadLine()
> Loop
> input.Close()
>
> For information on Unicode and Encoding in .NET see:
>
> http://www.yoda.arachsys.com/csharp/unicode.html
>
> Hope this helps
> Jay
>
> "James Wong" <cp_msdn@commercialpress.com.hk.NO_SPAM> wrote in message
> news:eWU9oTSdEHA.3132@TK2MSFTNGP11.phx.gbl...[color=green]
> > Dear all,
> >
> > I'm using StreamReader to read a text file containing BIG-5 data and[/color][/color]
found[color=blue][color=green]
> > that no matter which encoding method in StreamReader's construction
> > parameter, the BIG-5 contents become garbage under ReadLine method. Does
> > anybody have any idea on this issue?
> >
> > Thanks for your attention and kindly help!
> >
> > Regards,
> > James Wong
> >
> >[/color]
>
>[/color]


Closed Thread