Community Server

The platform that enables you to build rich, interactive communities
Welcome to Community Server Sign in | Join | Help
in Search

Strange problem with LF+CR characters in OUTPUT command

Last post 04-21-2010, 9:12 AM by Random Walker. 3 replies.
Sort Posts: Previous Next
  •  03-14-2010, 8:29 AM 113

    Strange problem with LF+CR characters in OUTPUT command

    John,

    I'm really puzzled with this one. I installed Stats101 on a different PC, using different folder paths by mistake. Quite obviously, my old programs failed to find the correct paths / files. After fixing the paths in the code, the programs are working fine, except for one case: the OUTPUT FILE command produces 0A (hexa) for the \n character, instead of 0A 0D, ie my output text file contains LF but no CR...and the output is unreadable.

    I tried reinstalled JRE 1.6.18, reinstalled Stats 1.4.7, and wrote a trivial program to output one line of text containing "\n". Same problem, the file shows a weird squarish character in Notepad (instead of a new line), and 0A (only) in a hex editor.

    The problem is probably with my PC, but I cannot figure out where I might have broken something. Both machines are running WinXP-SP2, and both were running stats101 fine 3 weeks ago. I haven't patched anything except JRE and Stats101.

    Any ideas of why OUTPUT might be doing something funny suddenly?

    PS: The WRITE command produces multiple lines correctly, and the OUTPUT command writes lines correctly on the screen (ie without FILE option).

    Gus
  •  03-14-2010, 7:19 PM 114 in reply to 113

    Re: Strange problem with LF+CR characters in OUTPUT command

    Gus,

    I found the problem. It's not your PC. Remember that OUTPUT didn't write to files until version 1.4.6. And that version also had the problem. I attempted a fix in 1.4.7, but that fix didn't fix it.

    Until the next version of Stats101, you can work around the problem by instead of using "\n" for your newlines, use "\r\n", which is Windows' new line sequence.

    Also, you should be able to read those files with WordPad (not Notepad). WordPad handles the endline characters properly.

    Let me know if that helps.

    John
  •  03-14-2010, 11:10 PM 115 in reply to 114

    Re: Strange problem with LF+CR characters in OUTPUT command

    Thanks John.

    Will test today. I'm fairly confident this is the issue:
    - on the other PC, I was using Notepad++, a programing editor.
    - on the new PC, I was using regular windows notepad until last night.

    I tried Notepad++ on the new PC last night, to make sure I was seeing the real characters...and discovered very nice features in Notepad++:
    1) file opens and displays as expected, correctly and straight away. That's why I didn't notice the problem earlier
    2) Status bar says my file is actually encoded in UNIX ANSI (but opened in Windows ANSI ;-)
    3) Slick editor feature to convert EOL to Windows ANSI

    Looking up the issue in Google, it seems its a common issue in Java programing on Windows systems. You may need to test under which OS the stats101 is running to OUTPUT correctly on each OS.

    PS: interesting observations:
    - WRITE doesn't have "visible" problem, files open correctly in windows notepad. I did not check if Notepad++ sees them as UNIX ANSI?
    - Stats101 reads back it's own UNIX ANSI files correctly (OUTPUT followed by READ), which means you may need to check the code there as well, as fixing OUTPUT might break READ.

    Thanks and best regards
    Gus
  •  04-21-2010, 9:12 AM 116 in reply to 115

    Re: Strange problem with LF+CR characters in OUTPUT command

    The problem has been fixed as of version 1.4.8 of Statistics101.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems