You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/01/26 17:26:16 UTC

[GitHub] [druid] gianm edited a comment on pull request #10795: Web console: allow encoding of ASCII control chars

gianm edited a comment on pull request #10795:
URL: https://github.com/apache/druid/pull/10795#issuecomment-767699168


   > I am only escaping char codes 0 to 0x1f so `\uNNNN` seemed like overkill. I have not considered (or ever used) `\NNN`. I use `\xNN` all the time in JS string literals. But I am down to do `\uNNNN`
   
   I don't think it's about overkill / underkill but more what people will expect. The underlying APIs are JSON so IMO it is best if the web console accepts JSON style escapes.
   
   > I have not considered (or ever used) `\NNN`.
   
   It's a C thing. I think we can skip it. It's only supported by Java, anyway, not JSON, and I think it makes more sense to stick to JSON.
   
   > Are there chars outside of 0 to 0x1f that should be encoded if we do `\uNNNN` ?
   
   I would accept exactly what JSON does, no more & no less:
   
   - `\"` -> `"`
   - `\\` -> `\`
   - `\/` -> `/`
   - `\b` -> ascii 8
   - `\t` -> ascii 9
   - `\n` -> ascii 10
   - `\f` -> ascii 12
   - `\r` -> ascii 13
   - `\uABCD` -> unicode code point ABCD for character in basic multilingual plane (test with non-latin languages)
   - `\uABCD\uEFGH` -> utf-16 surrogate pair ABCD EFGH (test with emojis like 🔥)
   
   That way, people can copy stuff freely back and forth between JSON specs and the web console fields.
   
   Note: the way unicode characters outside BMP are encoded here is not universal; for example Python would encode 🙂 as `\U0001F642` but JSON would encode it as `\uD83D\uDE42`.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org