Annoying Escape Character Squares in Notepad

This is a discussion on Annoying Escape Character Squares in Notepad within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hello, I'm generating text files using C and prefer to use notepad to open the results. Whenever something uses and ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Location
    Northern Va
    Posts
    18

    Cool Annoying Escape Character Squares in Notepad

    Hello,
    I'm generating text files using C and prefer to use notepad to open the results. Whenever something uses and escape character (eg "\n"), notepad will display a box character. When I open up the same document in any other text editor, the boxes turn into the proper format. If I then save it using that program and the same name and extension, I can open notepad and see my document formatted correctly.

    Example:

    I open "data.dat" and I see:
    Code:
    [NOTEPAD]
    #1 10 3.0 (box)#2 11 1.0 (box)...
    [WORDPAD]
    #1 10 3.0
    #2 11 1.0
    ...
    [AFTER SAVING IN WORDPAD AND GOING BACK TO NOTEPAD]
    #1 10 3.0
    #2 11 1.0
    ...
    It's not a problem or anything, it's just very annoying to use this intermediate step. This become especially apparent when notepad's memory-light structure is able to open something wordpad can't (eg 40,000+ lines). Sometimes though, I just have to break down and use a UNIX head,tail, or more.

    Any thoughts?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You are either:
    1. creating the data file in Linux/Unix and copying it to Windows.
    2. opening the file in binary form (e.g. fopen("mydata.txt", "wb")).

    In case 1, you need to use some sort of "unix2dos" tool to translate the file before using notepad [or use a text-editor that understands newlines without carriage returns, such as wordpad].
    In case 2, just remove the b when creating the file, so that it's a text-file to the system, rather than a binary.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    I am weary of Wordpad because it can mangle things similar to how Microsoft Word mangles things. I suggest Notepad++. Or you could also output a "\r\n" instead of just "\n".
    My Website

    "Circular logic is good because it is."

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    Definite to notepad++.
    The view whitespace will show you what crazy combination of spaces, tabs, \r and \n you have.
    Failing that, there's also a "view in hex" for getting down to the most basic level of bytes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Either the file has some non-Windows newlines, or you're typing the characters yourself. Are you pressing CTRL-ENTER or SHIFT-ENTER, by any chance? I think that creates a box character like that . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,985
    Problem is that notepad shows \n as squares for some stupid reason. Proper newlines of Windows is \r\n. Wordpad, word and other software (Notepad++ too, I believe?) shows \n correctly as newlines, however.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Why does Microsoft keep releasing that dysfunctional program? It works, yes, but only most of the time, and yet it's been around since, what 3.1 isn't it? You'd think they could've polish on it at some point.

    Then again, the software company I work for has let so many little bugs that we know about and just haven't wanted to spend the time to fix, so I guess it's a pretty universal phenomenon.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Started using Notepad++ and I'll never go back.

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,575
    Did you folks see the computer he was offered by one of the users when his cat ruined the former one sometime last year? (link shows a more recent model. He got the 2120, but I can't find it)

    Yup. Notepad++ here too.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Mario F. View Post
    Yup. Notepad++ here too.
    Me too. Awesome little app.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,985
    Quote Originally Posted by guesst View Post
    Why does Microsoft keep releasing that dysfunctional program? It works, yes, but only most of the time, and yet it's been around since, what 3.1 isn't it? You'd think they could've polish on it at some point.
    Well, they have polished it pretty much, but not enough to see \n as newlines, apparently.
    It's one thing I'd like to see fixed, though.

    Then again, the software company I work for has let so many little bugs that we know about and just haven't wanted to spend the time to fix, so I guess it's a pretty universal phenomenon.
    Amen to that. Heh.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Elysia View Post
    Well, they have polished it pretty much, but not enough to see \n as newlines, apparently.
    It's one thing I'd like to see fixed, though.
    Maybe it's good that they don't polish it too much. This way more people will start looking for better alternatives.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LoadFromFile() from a txt
    By Snoopy104 in forum C++ Programming
    Replies: 6
    Last Post: 03-14-2006, 10:05 AM
  2. Character handling help
    By vandalay in forum C Programming
    Replies: 18
    Last Post: 03-29-2004, 05:32 PM
  3. mygets
    By Dave_Sinkula in forum C Programming
    Replies: 6
    Last Post: 03-23-2003, 07:23 PM
  4. Hello and can someone help me??..
    By GGrrl in forum C++ Programming
    Replies: 3
    Last Post: 03-20-2003, 12:08 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 04:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21