Decode error when encountering accents chars
See original GitHub issueGood evening,
In some of the scripts i’m executing, people used accents chars in comments (not in vars at least! 😌 )
I created a small case that is easier to debug. The following code crashes :
duk_peval_string(ctx, "/* àéè */");
The error is : SyntaxError: decode failed (line 0)
If i remove the accents, everything works fine
Thansk in advance Best
R. Bloch
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
When Bad Things Happen to Good Characters
My character is an "e" with an acute accent, character code 233 (decimal) in ... If é is UTF-8 encoded, but displayed without...
Read more >html - E with accent doesn't show correctly - Stack Overflow
The browser displays these when it can't make sense of the numbers it is reading. UTF-8 is self-synchronzising. Unlike other multi-byte character encodings, ......
Read more >Unable to decode special characters - Boomi Community
Hi, I'm running into an issue when reading data from MySQL that contains special characters, specially Spanish accents.
Read more >Unicode HOWTO — Python 2.7.10 documentation
The Unicode Type¶ · errors argument specifies the response when the input string can't be converted according to the encoding's rules.
Read more >Unicode HOWTO - Python 3.7.0a2 documentation
For example, you can't fit both the accented characters used in Western ... The errors parameter is the same as the parameter of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The other school of thought is that UTF-8 decoding should in general be strict and always reject invalid sequences so that they can be detected and fixed. Pros and cons in each I guess.
I’ll improve the error message.
Yes usually it’s way more developer friendly to tolerate invalid char values and replace them like you said.
I agree on the replacement char solution, that would trivially solve 99% of the problems as usually the non proper chars are set in the comments.
Maybe another simpler improvement would be to just slightly change the error message to
SyntaxError: char decode failedWhich makes you understand immediately that you’ve some weird chars -> encoding. It’ll still be annoying as the dev will have to remove them somehow (src or on the fly) but at least he’ll be 100% sure of what is the problem. I think that just a
decode failedis not verbose enough.Best 👍