5

I have a file from Wild Wild Web and it contains malformed UTF8. I handled malformed UTF8 in my other codes in previous versions of Raku. In 2020.10 version, I am running into this issue below. Has the support for utf8-c8 changed (this page says it should work, but it doesn't seem to) :

https://docs.raku.org/language/unicode#index-entry-UTF-8_Clean-8

This page has this example:

say slurp($test-file, enc => 'utf8-c8');

Now my code on the command line:

raku -e 'my $a = slurp("zlist"); for $a.lines { .say }'
Malformed UTF-8 near bytes 73 e2 5f at line 55 col 14
  in block <unit> at -e line 1

Then using this:

raku -e 'my $a = slurp("zlist", enc => 'utf8-c8'); for $a.lines { .say }'
===SORRY!=== Error while compiling -e
Undeclared routine:
    utf8-c8 used at line 1

My code is simple and essentially copied from the example. What am I doing wrong?

Elizabeth Mattijsen
  • 25,654
  • 3
  • 75
  • 105
lisprogtor
  • 5,677
  • 11
  • 17
  • 5
    You've got single quotes around the `utf8-c8` and you've wrapped the whole thing in single quotes. If you change the quotes around `utf8-c8` to double or `<>` then it works just fine. – Scimon Proctor Feb 17 '21 at 10:23
  • Following on from @ScimonProctor 's suggestion, using `enc => q[utf8-c8]` works for me. – jubilatious1 Feb 17 '21 at 12:48
  • The general reason category for my close vote is shown as a standard stackoverflow / community-specific one, but the detailed reason is not shown. This comment is to let folk know it's the standard sub-reason "Not reproducible or was caused by a typo. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers." Point being that I'm presuming an answer won't help. If you think an answer might help then please ignore my close vote and don't vote to close. – raiph Feb 17 '21 at 14:43
  • Mia culpa ! Sorry ladies and gentlemen ! My fault ! Working too late at night and just couldn't get my mind to see the simplest bugs. – lisprogtor Feb 18 '21 at 06:09
  • FWIW, perhaps changing the title of the question to "Problem with quoting on the command line" may have been useful for future queries, as this question is a prime example of how it can trip you up *without* giving any error messages. – Elizabeth Mattijsen Feb 18 '21 at 10:20
  • Thank you Elizabeth Mattijsen ! Your comment is a great suggestion ! It would really help if Raku could tell quote and simple punctuation errors. – lisprogtor Feb 27 '21 at 20:37

0 Answers0