dprint-plugin-json icon indicating copy to clipboard operation
dprint-plugin-json copied to clipboard

Invalid UTF-8 chars prevent formatting

Open lucacasonato opened this issue 4 years ago • 2 comments

Describe the bug

deno fmt fails to format a JSON file because it contains invalid UTF8 chars.

dprint-plugin-json version: 0.10.2

Input Code

See https://gist.github.com/lucacasonato/a060df497ca3156327bcef46a554a8fb

Expected Output

A nicely formatted file, like prettier is able to generate.

Actual Output

Error formatting: /home/lucacasonato/Downloads/report.json
   Line 1, column 785340: Invalid unicode escape sequence. 'd834' is not a valid UTF8 character

  to ArrayBuffer with \ud834A\udf06A¥
                      ~~~~~~

lucacasonato avatar Jun 06 '21 15:06 lucacasonato

Related: https://github.com/dprint/jsonc-parser/issues/8

I think we will just have to make jsonc-parser handle invalid utf8 characters.

dsherret avatar Jun 06 '21 16:06 dsherret

A similar "\uD835\uDD04" can't be handled in typedoc when I looked at using dprint today, what's the path forward in jsonc-parser? I very briefly looked at doing this, but jsonc-parser's StringLit struct holds a Cow<'a, str>, and changing that seems like quite a major change...

Gerrit0 avatar Nov 26 '23 02:11 Gerrit0