On 18 May 2015, at 14:31, Ben Coman <btc@openinworld.com> wrote:
On Mon, May 18, 2015 at 6:49 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
I meant that writing '\r\n' has no effect in Pharo, this is not processed (you could do this manually, of course).
Is this something we should consider implementing to ease the way for newcomers? What downsides can you think of? cheers -ben
Nah, even in C, you need (s)printf for escape sequences to be interpreted. In any case, without error handling, this will do: | input escapes | escapes := { $n -> Character cr. $r -> Character lf. $\ -> $\ } asDictionary. input := 'foo\\bar\n\r'. String streamContents: [ :out | | in ch | in := input readStream. [ in atEnd ] whileFalse: [ ch := in next. ch = $\ ifTrue: [ out nextPut: (escapes at: in next) ] ifFalse: [ out nextPut: ch ] ] ] Sven