Re: Notepad: I'm seeing squares.
by Mutant (Priest) on Nov 23, 2005 at 15:29 UTC
|
\r\n should work for Windows. The problem could be in the way you're transferring the file between the two systems. | [reply] |
|
| [reply] [d/l] [select] |
|
While that might work, I don't have the liberty of copying the file back and forth between environments. I need to provide the user with a downloadable version of the file that will look as it should (i.e. - no squares).
| [reply] |
|
|
|
Re: Notepad: I'm seeing squares.
by ikegami (Patriarch) on Nov 23, 2005 at 15:47 UTC
|
I've tried to swap \n for \r\n
Like people have said, this should have worked. Notepad expects \r\n for line ends. Either 1) your file didn't use \n for line ends originally, or 2) you convertion code has a bug (and you probably ended up with \r\r\n).
A simple one liner to convert from \n to \r\n (when run from a Windows machine) is:
perl -pe1 infile > outfile
The above is similar to the following code:
open(my $fh_in, '<', $file_in)
or die("Unable to open $file_in: $!\n");
open(my $fh_out, '>', $file_out)
or die("Unable to create $file_out: $!\n");
print $fh_out $_
while <$fh_in>;
| [reply] [d/l] [select] |
Re: Notepad: I'm seeing squares.
by mikeock (Hermit) on Nov 23, 2005 at 15:47 UTC
|
If you are ftping the files from a *nix box, turn on binary first. | [reply] |
Re: Notepad: I'm seeing squares.
by marto (Cardinal) on Nov 23, 2005 at 15:09 UTC
|
Hi emilford,
On Windows I use notepad++ as a replacement for notepad. If downloading this is an option you may want to check it out. Are you able to use the unix2dos command to convert the file(s) before tranfering them?
Hope this helps.
Martin | [reply] |
|
Thanks for the suggestion, but I need a Perl solution.
| [reply] |
Re: Notepad: I'm seeing squares.
by pboin (Deacon) on Nov 23, 2005 at 15:48 UTC
|
You've got a bad assumption somewhere. "\r\n" on a unix-y perl will positively give you valid DOS carriage control. Open your file with a hex editor and you'll see something other than hex "0d0a" there for sure. That's the best way to shoot your problem.
| [reply] |
|
I viewed the file and the double squares do equate to 0D0A. That's what it's supposed to be right?
| [reply] |
|
Yes. x'0D0A' is valid DOS carriage control. But notepad shouldn't be putting up boxes for it. Any chance you can post your text file somewhere so others can test it? Or, maybe you can reproduce the problem w/ non-sensitive data.
| [reply] |
|
Re: Notepad: I'm seeing squares.
by Anonymous Monk on Nov 23, 2005 at 15:04 UTC
|
I think Wordpad handles this correctly. | [reply] |
|
It does, but I can't rely on everyone knowing that. Even if only one person attempts to open in Notepad and sees a bunch of squares and mashed together text, that's one too many in this case.
| [reply] |
|
| [reply] |
Re: Notepad: I'm seeing squares.
by swampyankee (Parson) on Nov 23, 2005 at 18:04 UTC
|
I'm probably going to get massive downvotes for this, but those little boxes, in my experience, mean that there are no glyphs associated with the character codes. (added in edit) Incorrect end-of-line markers (end of addition) That typically result in the text being squished onto one line; if you're "flooded with little squares" I don't think that the problem is the end-of-line markers.
Have you tried a) changing the font in Notepad, so see if the little boxes go away, b) opening the document in another editor see if the problem is unique to Notepad or c) explicitly creating the document in UTF-8?
Edited to make the 2d sentence comprehensible
| [reply] |
Re: Notepad: I'm seeing squares.
by Moron (Curate) on Nov 23, 2005 at 16:19 UTC
|
Another thought - what about opening it with OpenOffice, although you may still need to do a unixtodos on it first as marto suggested.
| [reply] |
Re: Notepad: I'm seeing squares.
by Moron (Curate) on Nov 23, 2005 at 15:31 UTC
|
How about making a copy of Win32::Word::Writer, re-engineering it into a Win32::Word::Reader and releasing it back to CPAN.
| [reply] |