Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF8-C8 string changes under concatenation #664

Closed
samcv opened this issue Aug 27, 2017 · 1 comment
Closed

UTF8-C8 string changes under concatenation #664

samcv opened this issue Aug 27, 2017 · 1 comment

Comments

@samcv
Copy link
Member

samcv commented Aug 27, 2017

use Test;
sub decode_utf8c {
    my @ints = 103, 248, 111, 217, 210, 97;
    my $b = Buf.new(@ints);
    my Str $u=$b.decode("utf8-c8");
    $u.=subst("a","b");
}
#?rakudo.jvm todo "Unknown encoding 'utf8-c8' RT #127878"
lives-ok &decode_utf8c, 'RT #127878: Can decode and work with interesting byte sequences';

This is a test in t/spec/integration/weird-errors.t (roast).

Or more simply, replacing a's with a's so the string should not be changed:

my @ints = 103, 248, 111, 217, 210, 97; my $b = Buf.new(@ints); my Str $u=$b.decode("utf8-c8"); say $u.chars; $u.=subst("a","a"); say $u.chars
#→  OUTPUT: «6␤9␤»

When re_nfg() in src/strings/ops.c gets called, it iterates by codepoint into the normalizer, losing the UTF8-c8 representation.

I discovered this by setting MVM_DEBUG_NFG

@samcv
Copy link
Member Author

samcv commented Oct 6, 2017

This has been closed with this commit 2f71945d

Closing :-)

@samcv samcv closed this as completed Oct 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant