Skip to content
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

Escape unicode character: u2028 #309

Open
twavv opened this issue Jul 27, 2020 · 1 comment
Open

Escape unicode character: u2028 #309

twavv opened this issue Jul 27, 2020 · 1 comment

Comments

@twavv
Copy link

twavv commented Jul 27, 2020

https://stackoverflow.com/questions/2965293/javascript-parse-error-on-u2028-unicode-character

This is mostly a non issue and only has to do with JS/JSON interop. tl;dr: not all JSON is valid JavaScript. It'd be nice if we replaced the unicode line ending character with the equivalent \u2028 to make the output parseable as JavaScript.

@mortenpi
Copy link

mortenpi commented Jul 27, 2020

Also \u2029: http://timelessrepo.com/json-isnt-a-javascript-subset

Technically, in ECMAScript 2019 (10th edition), it is no longer necessary, since the standard now allows U+2028 and U+2029 in strings. But it's probably better to err on the safe side (probably a lot of non-2019-compatible interpreters still out there) and just escape them. In Documenter we ran into this as well and we apply additional escapes on top of what JSON.json produces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants