Archived

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

GekkoCube

'\0' and editbox glitch!

Recommended Posts

GekkoCube    116
If ''\n'' is windows version for carriage-return + line-feed. Then the windows equivalent for ''\0'' is what? Second, I have this editbox in my MFC app - a really big editbox so the user can types a story in there if he/she wanted to. The problem is that if I type a bunch of words (maybe approx 50 or so) the cursor gets sent back to the top...AND when I type, it display the text backwards! If i typed hello (after the cursor gets set back to the top) it will display "olleh" Any idea what this glitch could be? I noticed that turning off UpdateData(TRUE) and UpdateData(FALSE) doesnt cause the problem to occur. ~ I am a DirectX to OpenGL convert! ~

Share this post


Link to post
Share on other sites
ELS1    127
quote:
Original post by GekkoCube
If ''\n'' is windows version for carriage-return + line-feed.
Then the windows equivalent for ''\0'' is what?

Second,
I have this editbox in my MFC app - a really big editbox so the user can types a story in there if he/she wanted to.
The problem is that if I type a bunch of words (maybe approx 50 or so) the cursor gets sent back to the top...AND when I type, it display the text backwards!

If i typed hello (after the cursor gets set back to the top) it will display "olleh"

Any idea what this glitch could be?
I noticed that turning off UpdateData(TRUE) and UpdateData(FALSE) doesnt cause the problem to occur.



~ I am a DirectX to OpenGL convert! ~


\r\n for edit box line return

Share this post


Link to post
Share on other sites
Oluseyi    2103
quote:
Original post by GekkoCube
If ''\n'' is windows version for carriage-return + line-feed.

Actually, it''s "\n\r."

quote:
Then the windows equivalent for ''\0'' is what?

Where ''\0'' is supposed to be what exactly?

As for your other question, I have no information at this time. Maybe later, or maybe someone else.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
GekkoCube    116
''\0'' is at the end of a string...
im guessing this is the problem....because i get this weird character, looks like a ''y'' with a '':'' turned 90 degrees on top.


~ I am a DirectX to OpenGL convert! ~

Share this post


Link to post
Share on other sites
merlin9x9    174
No matter what the system, \n is always "line feed" and \r is always "carriage return" (the "r" is for "return"). Now, Windows requires both to send the cursor to the beginning of the next line. Most other systems only need \n. Of course, those last two sentences only apply to the respective systems' APIs, not the C/C++ standard libraries.

Actually, I believe it's \r\n—I've always done it that way and it's always worked.

There are no platform-specific equivalents for \0. The \0 escape sequence signifies the terminator for the string. Since C-style strings are just arrays of characters, that's how most Windows API functions (and all C library functions), which use C-style strings, know where a string ends. You rarely have to deal with the terminator explicitly, unless you're doing some custom string manipulation that isn't handled by the C library. But even if you do, it's \0 on all platforms because it's part of the language.

[edited by - merlin9x9 on March 18, 2002 12:13:26 AM]

Share this post


Link to post
Share on other sites
jenova    122
\n\r

0xa/0xd

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
merlin9x9    174
Apparently, both \r\n and \n\r work (at least with MessageBox). I just tested it. But the conventional way to do it is carriage return, line feed; this is /r/n.

Share this post


Link to post
Share on other sites
PaladinGLT    122
Message box works fine with just \n so it doesn''t really work to test it there... do this.

char CrLf[2] = {0x0d, 0x0a};
MyTextBox.SetWindowText(CString("First Line") + CrLf + "SecondLine");

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Hi,
I believe your message box is performing translation from english to greek as "olleh" is like "hello" in greek.

Share this post


Link to post
Share on other sites