Join Nostr
2026-11-17 17:36:15 UTC

Axel Rauschmayer on Nostr: #JavaScript: JSON.stringify() only makes \r\n\t visible. Doing the same for other ...

#JavaScript: JSON.stringify() only makes \r\n\t visible. Doing the same for other invisible characters is surprisingly tricky:

> /^\p{Format}$/v.test('\u{200B}')
true
> /\p{Format}/v.test('👨‍👩‍👧‍👦')
true

AFAICT you have to:
• Use JSON.stringify()
• Split the result into graphemes via Intl.Segmenter
• Escape invisible characters
• Join to produce the final result