Issue with \n in output

May 5, 2014 at 3:03pm
Hello.

I have the following debug statement in my code:
1
2
3
#ifdef
 printf("testing \n")
#endif 

When i run the code in debug mode, instead of having output like:
testing
testing
testing
i would get some weird character like a music note for the newline escape sequence.

Does anyone know why?

Thanks in advanced!





May 5, 2014 at 3:16pm
Any chance you might have displayed a shift out (SO) character? This could cause extended ASCII characters to be displayed.

May 5, 2014 at 5:50pm
Im not sure. But the output is basically:

testing <a music note for \><0 with inverted background color> and repeat....

I have a picture of the output but i dont believe i can attach to the post.
May 5, 2014 at 6:35pm
Actually i think the extended ASCII character is being displayed. How do i fix that?

Thanks.
May 5, 2014 at 6:45pm
Code page 437 produces graphic character (eighth note) when ASCII CR (13) is printed to the display.

"\n" is getting translated to "\r\n" (for Windows newline sequence), but it is not displaying correctly.

What of the following things you using?
- OS
- Console Program
- Compiler
- Locale
May 5, 2014 at 7:10pm
i am using:
-windows server 2008
-win32
-visual studio
-english

i did a chcp in cmd and it showed the code page is 437...
May 5, 2014 at 7:32pm
I'm still not sure why printf() is not translating that CR properly.

It might be relevant: Are you in China (or round-abouts) using a Chinese-language version of Windows / language pack on Windows?

It might be that the translation to double-byte or shift-JIS or whatever your system is using is not happening properly with the printf(), causing the console to display it improperly.

I don't know what to do about it, either. You might need to find a version of libc that knows about internationalization. Or there might be a compiler switch in there somewhere to turn it on. Or you might just have to

setlocale( LC_ALL, "" );

at the top of your program, or something.

Sorry I can't be of more help.
May 6, 2014 at 2:47pm
I will give setlocale a try. If that doesn't work maybe i will try to do it on other computer.

Thanks for the help!
May 6, 2014 at 3:19pm
If it doesn't help, you should see if there is a forum about Chinese Windows versions and programming -- they are sure to have encountered this issue before.

I know very little about it -- I'm sitting in NJ USA with nothing more than basic Chinese language packs installed -- which do not modify my system significantly...
Topic archived. No new replies allowed.