Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
=begin pod :tag<perl6> | ||
=TITLE Newline handling in Perl 6. | ||
=SUBTITLE How the different newline characters are handled, and how to change the behavior. | ||
Different operating systems use different characters, or combinations of them, | ||
to represent the transition to a new line. Every language has its own set of | ||
rules to handle this. Perl 6 has the following ones: | ||
=item C<\n> in a string literal means Unicode codepoint 10. | ||
=item The default L<nl-out|/routine/nl-out> that is appended to a string by say | ||
is also C<\n> | ||
=item On output, when on Windows, the encoder will by default transform a C<\n> | ||
into a C<\r\n> when it's going to a file, process, or terminal (it won't do this | ||
on a socket, however). | ||
=item On input, on any platform, the decoder will by default normalize C<\r\n> | ||
into C<\n> for input from a file, process, or terminal (again, not socket). | ||
=item These above two points together mean that you can - socket programming | ||
aside - expect to never see a C<\r\n> inside of your program (this is how things | ||
work in numerous other languages too). | ||
X<|:translate-nl> | ||
=item The L<C<:$translate-nl>|/type/Encoding#method_decoder> named parameter | ||
exists in various places to control this transformation, for instance, in | ||
L<C<Proc::Async.new>|/type/Proc::Async#method_new> and | ||
L<C<Proc::Async.Supply>|/type/Proc::Async#method_Supply>. | ||
=item A C<\n> in the C<regex|/language/regexes> language is logical, and will match a C<\r\n>. | ||
=end pod | ||
|
||
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6 |