json_reindent icon indicating copy to clipboard operation
json_reindent copied to clipboard

UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 15: surrogates not allowed

Open octohedron opened this issue 7 years ago • 0 comments

Trying to format JSON with strings that contain encoded unicode surrogate characters crashes and deletes all the text in the buffer, which is very dangerous because you can't undo this action.

{
  "potato": "\ud83d"
}
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "sublime_json_reindent in /Users/user/Library/Application Support/Sublime Text 3/Installed Packages/JSON Reindent.sublime-package", line 25, in run
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime.py", line 639, in __getitem__
    r = sublime_api.view_selection_get(self.view_id, index)
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 15: surrogates not allowed

Related to #4 ?

octohedron avatar Dec 06 '17 10:12 octohedron