473,497 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Does RichTextBox need "\r\n"? Is "\n" good enough?

In VB, you use ControlChars.CrLf (or better, ControlChars.NewLine).
In C/C++, we are used to using merely "\n" (or at least I am). It
appears "\n" is good enough for RichTextBoxes. Does it matter? I am
so used to typing "\n" that I don't think this habit will change
anyday soon.

Zytan

Mar 2 '07 #1
8 12925
On 2 Mar 2007 14:21:03 -0800, Zytan wrote:
In VB, you use ControlChars.CrLf (or better, ControlChars.NewLine).
In C/C++, we are used to using merely "\n" (or at least I am). It
appears "\n" is good enough for RichTextBoxes. Does it matter? I am
so used to typing "\n" that I don't think this habit will change
anyday soon.

Zytan
Probably not -- but its good practice to use Environment.NewLine
--
Bits.Bytes
http://bytes.thinkersroom.com
Mar 3 '07 #2
Probably not -- but its good practice to use Environment.NewLine

Will do, thanks.

Zytan

Mar 3 '07 #3
On Mar 2, 5:12 pm, "Rad [Visual C# MVP]" <nos...@nospam.comwrote:
Probably not -- but its good practice to use Environment.NewLine
--
Bits.Byteshttp://bytes.thinkersroom.com
Why exactly is this this the preferred practice?

Mar 3 '07 #4
sherifffruitfly <sh*************@gmail.comwrote:
Probably not -- but its good practice to use Environment.NewLine

Why exactly is this this the preferred practice?
Well indeed. From my point of view, Environment.NewLine should be used
whenever you're writing a text file to be viewed on the current system,
but lots of people seem to use it whenever they want a new line,
regardless of the context.

I know various Windows controls *require* \r\n, but different platforms
and UI libraries may well use a different new line to what the platform
usually uses for text files.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 3 '07 #5
On Sat, 3 Mar 2007 07:18:02 -0000, Jon Skeet [C# MVP] wrote:
sherifffruitfly <sh*************@gmail.comwrote:
>>Probably not -- but its good practice to use Environment.NewLine

Why exactly is this this the preferred practice?

Well indeed. From my point of view, Environment.NewLine should be used
whenever you're writing a text file to be viewed on the current system,
but lots of people seem to use it whenever they want a new line,
regardless of the context.

I know various Windows controls *require* \r\n, but different platforms
and UI libraries may well use a different new line to what the platform
usually uses for text files.
I would still think it's a good idea to use it, like in the scenario the OP
raised. I've not used Mono but I would not be surprised if the equivalent
control for the rich text box required a \n on its own, in which case using
\r\n might break the code if compiled for Mono

Personaly i do it that way not for issues of cross platform compatibility
but because I invariably forget one slash...
--
Bits.Bytes
http://bytes.thinkersroom.com
Mar 3 '07 #6
Rad [Visual C# MVP] <no****@nospam.comwrote:
I know various Windows controls *require* \r\n, but different platforms
and UI libraries may well use a different new line to what the platform
usually uses for text files.

I would still think it's a good idea to use it, like in the scenario the OP
raised. I've not used Mono but I would not be surprised if the equivalent
control for the rich text box required a \n on its own, in which case using
\r\n might break the code if compiled for Mono
On the other hand, Mono may well have emulated Windows Forms as closely
as possible, in which case using Environment.NewLine may well break
text areas etc (in that you wouldn't get a new line). I feel sorry for
the Mono team on issues like that...
Personaly i do it that way not for issues of cross platform compatibility
but because I invariably forget one slash...
That must be pretty obvious when it happens though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 3 '07 #7
sherifffruitfly wrote:
On Mar 2, 5:12 pm, "Rad [Visual C# MVP]" <nos...@nospam.comwrote:
>Probably not -- but its good practice to use Environment.NewLine

Why exactly is this this the preferred practice?
Network protocols : use \r\n no matter what platform it is.

Files : use Environment.NewLine and have the platform
translate that to \r\n or \n or something third.

Multi line controls in screens : read the documentation very
carefully - I would expect \r\n to be the correct way no
matter what platform.

Arne
Mar 4 '07 #8
I find this page very useful for reference:

http://en.wikipedia.org/wiki/Newline

Mar 5 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2809
by: BJörn Lindqvist | last post by:
I think it would be cool if you could refer to instance variables without prefixing with "self." I know noone else thinks like me so Python will never be changed, but maybe you can already do it...
2
3059
by: Alexander Bartzas | last post by:
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...: > g++ packet.cpp radix.cpp route.cpp -o route There is no problem in the compilation of the code but when I try to run...
10
12814
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following...
6
2485
by: Erik R.N. | last post by:
Hi I have a ACCESS2002 table with a date-field in format "dd-mm-yyyy" which I "export" to a txt-file ( ; and " " ) and upload the txt-file to a MYSQL-table where the datefield is a varchar-field....
235
11490
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
5
9992
by: SenthilSS | last post by:
My application produces XML Data files which have XML namespace qualified XML elements (nodes), but the namespace itself is not declared in the data file. My task is to read these data files in a...
1
1859
by: Bernd Hohmann | last post by:
I have a question about using "*" in (sub)queries. This example query counts the number of records for a certain customer starting with record "80172" and stops after 10 rows. SELECT...
2
6470
by: SharpCoderMP | last post by:
hi, i'm writing a console application and i would like to be able to safely retrive password from the user, so noone can see how it is being typed. consider this scenario: Console.Write("Enter...
5
13299
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.