Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » CR visibile with notepad
CR visibile with notepad [message #18191] Mon, 15 September 2008 15:00 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

the ASCII file I'm generating have, when showed by a simple editor as notepad, a rectangular empty box at the place of the invisible carriage return (see after the word "Master")

index.php?t=getfile&id=1376&private=0

Notepad does not recognize it as a real CR. In wordpad instead it does not appear and works ok. In the past this character did not appear with notepad.
Because it is causing problem during the parsing of the txt file I would like to know if it is normal.

The txt file is generated by code like this

FileOut out(filename);
out << NFormat( "%-30.30s\n", NAMETORNEO);
out << NFormat( "%-30.30s\n", PLACETORNEO);
...

Thanks,
Luigi
  • Attachment: pic2.jpg
    (Size: 28.05KB, Downloaded 554 times)
Re: CR visibile with notepad [message #18192 is a reply to message #18191] Mon, 15 September 2008 15:28 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Notepad requires old MS-DOS end of line.
Wordpad does work even with UNIX end of line style.

See for example: http://ccrma-www.stanford.edu/~craig/utility/flip/
for more information.

Basically you somehow managed to tell C++ to translate "\n" as 0x0A (or 0x0D only, one of those, check binary hex view if you have some handy viewer at hand).
How to fix that ... either switch the C++ compiler back to MS-DOS like line endings, or instead of "\n" use "\015\012".

Or stop using notepad :/
Re: CR visibile with notepad [message #18196 is a reply to message #18192] Tue, 16 September 2008 10:07 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mr_ped wrote on Mon, 15 September 2008 15:28

Basically you somehow managed to tell C++ to translate "\n" as 0x0A (or 0x0D only, one of those, check binary hex view if you have some handy viewer at hand).
How to fix that ... either switch the C++ compiler back to MS-DOS like line endings, or instead of "\n" use "\015\012".


Hi,

"\n" is translated 0x0A but I am not responsible... at least I believe. The code remained the same and in the past the char was not visible.
Now it appear both with mingw and msc9. It seems that 0x0A give problem during the parse.
Thanks,
Luigi
Re: CR visibile with notepad [message #18210 is a reply to message #18192] Tue, 16 September 2008 20:04 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mr_ped wrote on Mon, 15 September 2008 15:28


Basically you somehow managed to tell C++ to translate "\n" as 0x0A (or 0x0D only, one of those, check binary hex view if you have some handy viewer at hand).
How to fix that ... either switch the C++ compiler back to MS-DOS like line endings, or instead of "\n" use "\015\012".



I have discovered that if I use

out.PutLine( astring );

in Windows is automatically added \r\n instead of the simple \n.
This resolve my problem.
Thanks,
Luigi
Re: CR visibile with notepad [message #18213 is a reply to message #18191] Wed, 17 September 2008 08:57 Go to previous message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
And the PutLine does use PutEol which is defined as PutCrLf under Win32 platform.
Keep in mind, while using U++ Eol function, if you do a non-win32 version of your software, it will produce the text files with simple \n only, just your windows version will produce \r\n files.
So text files generated with linux version will be still "broken" in windows Notepad.

And reading this source I also started to realize the C++ probably always does compile "\n" as 13, so when you want MS-DOS line ends, you have to write "\n\r" everywhere...

Can't we just get rid of notepad instead? It's very annoying.
Just as MS codepages vs utf8... This windows thing feels to me like a big stone attached to leg in recent years, and MS keep insisting on the obsolete concepts even with new version, so there's no light at the end of the tunnel.
Previous Topic: Is there a way to fetch objects w/o default constructor?
Next Topic: C++ parsing
Goto Forum:
  


Current Time: Mon Apr 29 17:13:18 CEST 2024

Total time taken to generate the page: 0.02652 seconds