Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\n should be 0x0d 0x0a on win32 #2406

Closed
p6rt opened this issue Apr 15, 2011 · 7 comments
Closed

\n should be 0x0d 0x0a on win32 #2406

p6rt opened this issue Apr 15, 2011 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Apr 15, 2011

Migrated from rt.perl.org#88674 (status was 'resolved')

Searchable as RT88674$

@p6rt
Copy link
Author

p6rt commented Apr 15, 2011

From patrick.abisalloum@gmail.com

On windows 7 and vista using "\n" does not produce \r\n

The following

my $file = open('foo.txt', :w);
$file.say("a\nb");
$file.close;

produces a file containing the bytes

61 0a 62 0a

The expected bytes are

61 0d 0a 62 0d 0a

A current work around is to use

$file.print("a\r\nb\r\n");

@p6rt
Copy link
Author

p6rt commented Mar 9, 2015

From wbiker@gmx.at

Hi,

Following script on Windows​:

use v6;

my $fh = open('test.txt', :w);

$fh.say("hello");
$fh.say("Perl6");

$fh.close;

produced following file​:

helloPerl6

Also on Windows say uses \n instead of \r\n

THX

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

From @mattn

On 2015-3月-08 日 23​:41​:49, wbiker@​gmx.at wrote​:

Hi,

Following script on Windows​:

use v6;

my $fh = open('test.txt', :w);

$fh.say("hello");
$fh.say("Perl6");

$fh.close;

produced following file​:

helloPerl6

Also on Windows say uses \n instead of \r\n

THX

I think using \r\n is non-sense in 2015. We can use \n instead of \r\n. Why need \r\n? Let's throw away such as compatibility with Perl5. Many perl users on windows have been plagued by differences of each OS.

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 9, 2015

From wbiker@gmx.at

hmm.
\r\n is not a Perl5 compatibility issue. WIndows uses \r\n by default while
\r is used on Linux and Mac. So, you have to convince Microsoft to change
WIndows behavour not Perl :-)

greetings
wolf

On 8 October 2015 at 17​:49, Yasuhiro Matsumoto via RT <
perl6-bugs-followup@​perl.org> wrote​:

On 2015-3月-08 日 23​:41​:49, wbiker@​gmx.at wrote​:

Hi,

Following script on Windows​:

use v6;

my $fh = open('test.txt', :w);

$fh.say("hello");
$fh.say("Perl6");

$fh.close;

produced following file​:

helloPerl6

Also on Windows say uses \n instead of \r\n

THX

I think using \r\n is non-sense in 2015. We can use \n instead of \r\n.
Why need \r\n? Let's throw away such as compatibility with Perl5. Many perl
users on windows have been plagued by differences of each OS.

@p6rt
Copy link
Author

p6rt commented Nov 5, 2015

From @jnthn

On Fri Apr 15 12​:06​:47 2011, patrickas wrote​:

On windows 7 and vista using "\n" does not produce \r\n

The following

my $file = open('foo.txt', :w);
$file.say("a\nb");
$file.close;

produces a file containing the bytes

61 0a 62 0a

The expected bytes are

61 0d 0a 62 0d 0a

A current work around is to use

$file.print("a\r\nb\r\n");

Now \n in strings is "magical"​: it will default to CRLF on Windows, and just LF elsewhere (you can see what $?NL contains to check). It can be controlled by the newline pragma when this default is not appropriate, tests for which are in S16-io/newline.t.

Thanks,

Jonathan

@p6rt p6rt closed this as completed Nov 5, 2015
@p6rt
Copy link
Author

p6rt commented Nov 5, 2015

@jnthn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant