Emit UTF-8 unescaped in string section #9259
When printing text modules, where size doesn't matter, but readability does, I would err on the side of using more escapes to avoid accidentally emitting unprintable unicode characters, so I wouldn't want to make the change here unless we were really confident that isPrintableUTF8 was exhaustive.
There are many additional kinds of unicode control characters: https://en.wikipedia.org/wiki/Unicode_control_characters.
Trying to implement our own correct version of this function is probably not worth the effort, and we don't want to pull in a library like ICU, so we should at least default to saying a character is not printable unless we know for sure that it is.
If we're writing raw UTF-8 and don't care about writing control characters, then why check for u >= 0x80 here?
It looks like there a few separate changes here: fixing JSON decoding to handle arbitrary UTF-8 (uncontroversial), emitting raw UTF-8 in the string section (probably ok, but hopefully nobody uses the string section), and printing more UTF-8 in wat custom sections (dangerous).
It might be helpful to separate them into separate PRs so we can discuss them individually.
tlively
stevenfontanella
Saves some bytes in the string section when non-magic string lowering is used.
Also resolves some TODOs, and fixes unescapeUTF8JSONtoWTF16 which previously didn't handle UTF-8 sequences.