[Rio-pm] função chomp

Randal L. Schwartz merlyn em stonehenge.com
Segunda Junho 27 12:16:33 PDT 2011


>>>>> "Andre" == Andre Carneiro <andregarciacarneiro at gmail.com> writes:

Andre> André e Stan
Andre> A palavra-chave aqui é TERMINADOR. O terminador é sempre o último, ou
Andre> últimos caracteres que definem a quebra de linha. Isso pode variar entre
Andre> plataformas, por exemplo: no windows, o terminador é representado pelos
Andre> caracteres \r\n( 'Retorno do carro' + 1 linha), referenciando os velhos
Andre> 'carros' de máquina de escrever. Em Unix/Linux/BSD etc o caracter terminador
Andre> é \n, e Mac é \r(se não me engano...).

The external representations of the line ending for Unix is \cJ, for
windows \cM\cJ, and for Mac prior to OSX \cM (OSX is unix, so you get
\cJ back again).

However, the *internal* representations of all of those were always \n.
Whether you were on a Mac or Windows or Unix, you always got lines that
ended in \n.

So chomp always removes \n - the native "newline".

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion


Mais detalhes sobre a lista de discussão Rio-pm