Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport higher Unicode ranges for Char.fromCode #687
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Aug 9, 2016
Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Aug 9, 2016
|
Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lukewestby
Aug 11, 2016
Member
Unfortunately String.fromCodePoint isn't well supported by browsers so it would need to be polyfilled. Even a low-level polyfill of this function is a lot slower than the native, as demonstrated by the benchmark below
|
Unfortunately |
lukewestby
added
the
request
label
Aug 20, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Mar 25, 2017
Member
Fixed in elm-lang@bf16ca8 with an implementation that is cross-browser and should be reasonably fast. In the BMP, it usually adds just one check, so it's not much of an additional overhead.
@lukewestby, most polyfills have lots of code to handle all the bad data that could be passed in. What does .codePointAt do on objects? On arrays? Etc. In this case I just learned a lot about UTF-16 for some recent parser work, and it turns out that it's not so hard to sort out.
If folks are curious, I used the formulas from here for surrogate pairs.
|
Fixed in elm-lang@bf16ca8 with an implementation that is cross-browser and should be reasonably fast. In the BMP, it usually adds just one check, so it's not much of an additional overhead. @lukewestby, most polyfills have lots of code to handle all the bad data that could be passed in. What does If folks are curious, I used the formulas from here for surrogate pairs. |
Janiczek commentedAug 9, 2016
I'm trying 0x1F0A1 = 🂡, I'm getting 0xF0A1 = .
That's because Elm uses JavaScript's
String.fromCharCodewhich doesn't support higher Unicode ranges.To mitigate that,
String.fromCodePointshould be used.As a sidenote, maybe
toCodecould be also updated to useString.codePointAtinstead ofString.charCodeAt?