You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example code is wrong in that the getc method will always wait for additional input in order to determine whether it is a combining character or not.
To actually do raw input, you need to set the IO::Handle (e.g. $*IN) to binary mode ($*IN.encoding(Nil);) and use $*IN.read(1) to read a single byte; note that this will give you a Buf instead of a Str. (A quick hack for that is $*IN.read(1).decode("latin-1"), especially since Buf is currently not as easy to work with as Str.)
The raw input mechanism may require a somewhat recent moarvm and matching rakudo to work properly.
The text was updated successfully, but these errors were encountered:
I have made a module Unicode::UTF8Parser that parses UTF8 chars from a stream without waiting for combining chars. I can change the example to use this module.
I have held back doing this, as I think Rakudo should expose this as some kind of parser mode. It seems silly to reimplement a full UTF8 parser in plain perl6. Also, I am not sure how Rakudo will handle un-normalized unicode (that is, with base char and combining chars separately). I have used it myself without much problems though - the strings seems to become normalized quite quickly.
The example code is wrong in that the
getcmethod will always wait for additional input in order to determine whether it is a combining character or not.To actually do raw input, you need to set the
IO::Handle(e.g.$*IN) to binary mode ($*IN.encoding(Nil);) and use$*IN.read(1)to read a single byte; note that this will give you aBufinstead of aStr. (A quick hack for that is$*IN.read(1).decode("latin-1"), especially sinceBufis currently not as easy to work with asStr.)The raw input mechanism may require a somewhat recent
moarvmand matchingrakudoto work properly.The text was updated successfully, but these errors were encountered: