Objectmix
Tags Register Mark Forums Read

StreamReader and NULL characters : DOTNET

This is a discussion on StreamReader and NULL characters within the DOTNET forums in Framework and Interface Programming category; Duh! I should have thought about that. The first NULL char will destroy display at that point. -- Gregory A. Beamer MVP, MCP: +I, SE, SD, DBA Subscribe to my blog http://gregorybeamer.spaces.live.com/lists/feed.rss or just read it: http://gregorybeamer.spaces.live.com/ ************************************************* | Think outside the box! | ************************************************* <brian.gabriel @ gmail.com> wrote in message news:25613de2-2c3d-4898-8f5d-8073d6ab418d @ e60g2000hsh.googlegroups.com... Thanks Jon! After seeing your example I created a much small text file with the offending characters and was able to better debug the issue. The issue is not with the StreamReader, but with displaying the results in a text box. A simple Replace removed the ...


Object Mix > Framework and Interface Programming > DOTNET > StreamReader and NULL characters

DOTNET Discussion forums related to Microsoft Dot net technologies, CSharp and other related items

Reply

 

LinkBack Thread Tools
  #11  
Old 03-25-2008, 07:19 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: StreamReader and NULL characters

Duh!

I should have thought about that. The first NULL char will destroy display
at that point.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
<brian.gabriel@gmail.com> wrote in message
news:25613de2-2c3d-4898-8f5d-8073d6ab418d@e60g2000hsh.googlegroups.com...
Thanks Jon!

After seeing your example I created a much small text file with the
offending characters and was able to better debug the issue. The
issue is not with the StreamReader, but with displaying the results in
a text box. A simple Replace removed the offending characters and
everything is displaying properly.

Again thanks for the help.

Brian
brian.gabriel@gmail.com

On Mar 24, 9:20 am, Jon Skeet [C# MVP] <sk...@pobox.com> wrote:
> Could you give an example of this, bearing mind my earlier example?
> Here's another example using the OP's sample data - again, it doesn't
> show StreamReader failing with null characters:
>
> using System;
> using System.IO;
> using System.Text;
>
> class Test
> {
> static void Main(string[] args)
> {
> // A B
> byte[] data = { 65, 66, 0x0d, 0x0a, 0,
> 0x0c, 0x0d, 0x0a, 67, 68};
>
> using (MemoryStream stream = new MemoryStream(data))
> using (StreamReader reader = new StreamReader(stream))
> {
> string line;
> while ((line=reader.ReadLine()) != null)
> {
> Console.WriteLine ("Next line:");
> for (int i=0; i < line.Length; i++)
> {
> Console.WriteLine("{0}: {1}", i,
> line[i]=='\0'
> ? "NUL"
> : line[i].ToString());
> }
> }
> }
> }
>
> }
> > A method I employed, at one time, for EBCDIC, is running everything
> > binary
> > until it needed to be text. Much more efficient to stay in the binary
> > world,
> > from a perf perspective, but also harder to program, as we do not think
> > in
> > 0s and 1s. :-)

>
> It also means that *you* need to worry about all the nasty issues of
> text handling rather than getting the framework to do it.
>
> --
> Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet
> Blog:http://www.msmvps.com/jon.skeet
> World class .NET training in the UK:http://iterativetraining.co.uk



Reply

Thread Tools



All times are GMT -5. The time now is 08:49 AM.

Managed by Infnx Pvt Ltd.