-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Hex Entities Incorrectly Converted to Unicode #140
Comments
Astral plane chars are going to fail because it's calling String.fromCharCode on the parsed int, which only looks at the two right-most bytes. What you want is for the string to be "\ud83d\udd25", with the surrogate pair split up. I'd accept a patch that properly split up surrogate pairs before calling String.fromCharCode(). For example:
|
Seems as if we both came to the same conclusion, you may want to move your comment over to the other issue (in the sax project) since it's a little more pertinent there. I think the best solution would be to use the Anyhow, this seems to be an issue in the XML/SVG parser, that is manifesting in some cases within SVGO. |
Oh, whoops, I commented on the wrong place :) Will repost over there. |
Fixed by sax 0.6.0. Thanks to @mathiasbynens for writing a String.fromCodePoint shim. |
ok, thank you guys! |
this seems not to work attributes. eg: |
While optimizing an SVG font file, I ran across an interesting issue with the encoding of hex entities.
All of the hex entities were converted to their unicode counterpart (a great optimization), however they were incorrectly encoded. For example, the hex entity
🔥
should have been converted to 🔥, but instead it was converted to
. Upon further inspection, I concluded that the hex entity for the resulting character was
.It appears the the
1
has been stripped from the hex entity before it was converted, leading to an incorrect conversion.Here is a test:
svgo -s "<svg>🔥</svg>" -o -
The text was updated successfully, but these errors were encountered: