[Mono-list] WriteLine of string with trailing \0's

Robert Jordan robertj at gmx.net
Mon Aug 2 15:13:54 EDT 2010


On 02.08.2010 20:35, Matt Calder wrote:
> Hi,
>
> I had some trouble debugging code that was working with fixed length
> strings. After a fair amount of debugging in the wrong direction, I
> discovered the issue boiled down to the question of what should be
> printed by this line:
>
> System.Console.WriteLine("[\0\0\0]");
>
> On mono (2.6.3) running on Ubuntu (10.04) this prints "[]". On Windows
> this prints "[   ]". Should they be the same? and if so, which is
> right?

If you redirect the output to a file you'll find out
that the \0 is actually emitted.

However, Unix terminals do not display \0 (NULL).

Robert



More information about the Mono-list mailing list