I have a very simple .NET program. It's just to write a string to the textbox. There is a strange character appearing at the end of my string.
This happens only on my 32-bit XP box. The same program works fine on another 64bit Windows 2008 machine.
The program is as simple as this.
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = "Hello\n\0\0\0\0\0\0";
}
I know it's odd to add \0 at the end of the string and I can trim them before applying to the textbox. The textbox is set to allow multi-line.
Just out of curiousity, does anybody know where the problem comes from? Both machines got .NET 3.5 SP1 installed. Both of them are set to have the same regional settings. I doubt if it is related to 32-bit or 64-bit.
UPDATE
Thanks to @DBM and @Andrew. The strange character is coming from \n but nothing to do with \0. Now, it sounds like Windows 2008 can understand both \r\n and \n. Can anybody confirm that?
Standard end-of-line sequence in Windows is \r\n
. The text box isn't recognising the \n
as a new-line without the preceding carriage return (\r
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With