Ticket #1793 (closed bug: invalid)
FileHandles do not properly transcode strings
Reported by: | pmichaud | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | core | Version: | 2.7.0 |
Severity: | medium | Keywords: | |
Cc: | Language: | perl6 | |
Patch status: | Platform: |
Description
The following program creates three strings with exactly the same (logical) 2-character contents and verifies that the strings are equal. However, when output to a filehandle set to use utf8 encoding, the strings produce different results -- the non-utf8 string isn't properly transcoded to the utf8 encoding used by the filehandle.
pmichaud@orange:~/parrot/trunk$ ./parrot_config revision 48985 pmichaud@orange:~/parrot/trunk$ cat a.pir .sub main :main # set output encoding to utf8 $P0 = getstdin $P0.'encoding'('utf8') # Build three strings of two characters each .local string a, b, c a = unicode:"\x{c3}\x{a9}" # U+00C3 followed by U+00A9 $S0 = chr 0xc3 $S1 = chr 0xa9 b = concat $S0, $S1 # U+00C3 followed by U+00A9 c = concat unicode:"", b # U+00C3 followed by U+00A9 # Show that they're all equal print "a eq b == " $I0 = iseq a, b say $I0 print "a eq c == " $I0 = iseq a, c say $I0 print "b eq c == " $I0 = iseq b, c say $I0 # Display them say a say b say c .end pmichaud@orange:~/parrot/trunk$ ./parrot a.pir a eq b == 1 a eq c == 1 b eq c == 1 é é é pmichaud@orange:~/parrot/trunk$
In the above sample run, I expect the last three lines to produce the same output since the strings themselves are equivalent. (One can do a hex dump of the output to verify that the middle string is different from the other two.)
Thanks!
Pm
Change History
Note: See
TracTickets for help on using
tickets.