Re: Idea for Reader optimisation for reading

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tian Min Huang (timhuang_at_online.microsoft.com)
Date: 02/25/04


Date: Wed, 25 Feb 2004 08:39:16 GMT

Hello,

Thanks for your feedback. I understand your concerns, and now I'd like to
share the following information with you:

1. Did you specify the encoding when creating the BinaryReader? If you did
not specify, it will use UTF8Encoding and I believe that may be the reason
why PeekChar may return -1 on some characters. I suggest you to use ASCII
encoding as the following to check if it works:

   BinaryReader r = new BinaryReader(fs, System.Text.Encoding.ASCII);

2. In addition, I do not recommend you use PeekChar to check the EOF
because it also returns -1 when the underlying stream does not support
seeking. Alternatively, I suggest that you can get the length of file and
then get the bytes in a loop. Please refer to the following code snippet:

//--------------------code snippet--------------------
FileInfo fi=new FileInfo(FILE_NAME);
FileStream fs = fi.OpenRead();
BinaryReader r = new BinaryReader(fs);

// Read data
for(int n =0; n<fi.Length; n++)
{
        Console.WriteLine(r.ReadByte());
}
.....
//--------------------------end of----------------------

I am standing by for your feedback.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.



Relevant Pages

  • Re: Data source not "sticking"
    ... First, as far as I am aware, when the data source is a text file and you ... have to specify the encoding, Word does not store the information about the ... encoding when it saves the mail merge main document. ... XML format (i.e. not the sort of simple XML format doucment you might ...
    (microsoft.public.word.docmanagement)
  • Re: Uniquely identifying Sudoku grids
    ... |> uniquely specify every possible sudoku. ... |So you'd need 22 digits to uniquely specify a sudoku puzzle. ... deck of 52 cards +2 jokers, how many poker hands are ... or some such encoding that can be easily ...
    (rec.puzzles)
  • Re: =?UTF-8?B?77u/V2hlbg==?= X.ZIP downLoads a post or eMail, Windows-1252 is the default.
    ... It's very common for a newsReader to specify ISO-8859-1 ... doesn't fit into the ISO standards. ... | When a user agent would otherwise use an encoding given in the ... mis-identified as using ISO standard character encodings. ...
    (news.software.readers)
  • Re: Print Spanish characters in Perl?
    ... and ensure that your file is saved in the UTF-8 format. ... encoding then your display device expects. ... forgetting to specify UTF-8 as charset. ... To avoid this kind of problem, make sure that all the characters are ...
    (comp.lang.perl.misc)
  • Re: Why doesnt strrstr() exist?
    ... > Unicode is a character set, not an encoding. ... > AFAIK the language doesn't specify how to deal with Unicode ... I am not *that* familliar with Java. ...
    (comp.lang.c)