mathiasbynens / esrever

A Unicode-aware string reverser written in JavaScript.
https://git.io/esrever
MIT License
891 stars 30 forks source link

Incorrect reversal of "noël" #10

Closed nathanl closed 8 years ago

nathanl commented 8 years ago

esrever.reverse("noël") returns "l̈eon". It should return "lëon".

(From https://mortoray.com/2013/11/27/the-string-type-is-broken/)

mathiasbynens commented 8 years ago

I cannot confirm this issue. I’ve copy-pasted the string noël from your GitHub comment — it’s the string 'noe\u0308l'.

$ node -p "require('esrever').reverse('noël')"
lëon

$ esrever -v
v0.2.0

$ esrever noël
lëon

https://mothereff.in/reverse-string#noe%CC%88l also shows the correct result.

What makes you think there is a bug?

nathanl commented 8 years ago

@mathiasbynens Sorry. I may not know How To Javascript™. 😆 When I use node to run it from the command line as you show, I get the correct result.

What I tried before was to go to your source in Chrome (Version 51.0.2704.103 (64-bit)), copy-paste the code into the console so that esrever would be defined, and try it from there. In that case, it looks wrong.

wrong_reversal_in_console

You probably have better things to do, but if you feel like taking time to tell me why that doesn't/shouldn't work, I'd appreciate it.

Either way, sorry to bother you with an invalid bug report.

mathiasbynens commented 8 years ago

That’s the uncompiled source, not the actual source code. The <%= %> give it away. src/esrever.js is used as a template to generate esrever.js at build time.

I could probably make that clearer by renaming src/esrever.js to something like src/esrever.js.tpl but then again I don’t wanna lose syntax highlighting…

nathanl commented 8 years ago

Ah, thanks for clarifying! BTW - after posting this I came across some of your articles on Unicode support in Javascript. Excellent work! 👍