Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Olrich

Help with '\n' escape sequence

This topic is 5738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Right now i am programming a MFC Application that has a CEdit that needs to display multiple lines of text. When I first started this project adding \n to a CString then displaying it in the box got to the next line. However, now when I use \n all i get is a wierd character that sort of looks like this ''|''. Thanks

Share this post


Link to post
Share on other sites
Advertisement
sometimes you need both a \n AND \r

respectivly newline and carriage return...

Cant remberer if it''s \n\r or \r\n but experiment...

ps. if that doesn''t work then you are not ment to make linebreaks there...

pps.

\n only = linux & unix style
\n and \r = MS wierdness
\r = MAC wierdness

:D

Share this post


Link to post
Share on other sites
I might me wrong about this, but I believe that in the early days, \r\n (carriage return/line feed) was a holdover from typewriters where you would actually do both of those things to advance to a new line. However, since space was of major importance, MS decided that they could only store the \n and have it represent both of them while Unix decided to stick with \n only. With XP and/or .NET and/or recent updates to anything they switched to requiring both the \r and \n for a newline. If you read an ASCII file in as binary you''ll notice that newlines are two bytes (10 and 13, not sure which is which).

There is my useless addition to this topic.




"Back to the code mines... ka-chink... ka-chink..."
Tachyon Digital

Share this post


Link to post
Share on other sites
quote:
Original post by Olrich
Thanks man. It was \r\n...I wonder why \n by itself worked before....oh well thanks for the help.


This depends of the encoding... Unicode use both of \r and \n while ANSI - not. If you moved to another platform (WinXP) this is the reason for your problem... Or there may be another reasons for changing encoding

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!