devalue icon indicating copy to clipboard operation
devalue copied to clipboard

Escape non-ascii characters?

Open Conduitry opened this issue 7 years ago • 1 comments

Ref: https://github.com/sveltejs/svelte.technology/issues/236

This might be something that would be nice. It would have avoided the above issue. If the goal is to produce javascript to re-create the same object, it'd be cool if that javascript were resilient to charset issues.

Conduitry avatar Mar 27 '18 16:03 Conduitry

I'm encountering a similiar problem in production as well. You get UGC data in your database, then you are playing russian roulette.

JSON.parse(devalue.stringify(decoder.write(Buffer.from([0x11]))))
Uncaught SyntaxError: Unexpected token ◄ in JSON at position 2

//compared with
JSON.parse(JSON.stringify(decoder.write(Buffer.from([0x11]))))
'\x11'

ncoder avatar Mar 09 '23 01:03 ncoder