id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,lang,patch,platform
1793,FileHandles do not properly transcode strings,pmichaud,,"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",bug,closed,normal,,core,2.7.0,medium,invalid,,,perl6,,
