-
March 19th, 2014, 07:01 AM
#1
Isuue with /n in Qt Creator
Hi everybody !
I am using Qt Creator with VS2012 compiler.
I declared a QByteArray variable : T
I initialized it. Everything OK.
I added the line :
What follows gives me an exception and I think that the issue comes from this added line. As I take a look at T in the debugger, I don't see any \n but a point .
Could you explain please ?
Many thanks.
-
March 19th, 2014, 08:22 AM
#2
Re: Isuue with /n in Qt Creator
"\n" is not a byte but char array (more precisely: a pointer to the first element of the char array)
So why do you add it to the QByteArray instance?
Perhaps you wanted to do
Victor Nijegorodov
-
March 19th, 2014, 08:28 AM
#3
Re: Isuue with /n in Qt Creator
I mean LF that has ascii code 10.
Why can't I see in the debugger window. It's displayed as a "."
-
March 19th, 2014, 08:40 AM
#4
Re: Isuue with /n in Qt Creator
How it is displayed depends on the debugger or/and IDE.
How did you expect it to be displayed?
Victor Nijegorodov
-
March 19th, 2014, 08:45 AM
#5
Re: Isuue with /n in Qt Creator
For example, I expected to see:
T "On the air\n"
-
March 19th, 2014, 08:47 AM
#6
Re: Isuue with /n in Qt Creator
And I see :
T "On the air."
-
March 19th, 2014, 08:50 AM
#7
Re: Isuue with /n in Qt Creator
Originally Posted by mulfycrowh
For example, I expected to see:
T "On the air\n"
Hmm, I never saw any debugger showing LF as '\n'" in a debugger window.
Note that LF (as well as CR, TAB and many others) are non-printable symbols! And displaying them as '\n' (or '\r', '\t') would confuse user because he/she would think there are two characters: backslash and 'n'!
Victor Nijegorodov
-
March 19th, 2014, 09:59 AM
#8
Re: Isuue with /n in Qt Creator
lf, cr, tab etc are non-printable chars in the ASCII code set. These type of chars are shown as a '.' when trying to display text. If you want to see these non-printable chars then you will need to display in hex when lf will shown as 0a etc.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 19th, 2014, 10:04 AM
#9
Re: Isuue with /n in Qt Creator
Ok but I have another computer running another software in Qt Creator. It displays the string as \n. So I don't understand. I looked for some settings in Qt Creator but I didn't find anything. Weird ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|