keys.json with CJK characters

Solved bugs are moved into this topic...
Post Reply
SamC
Posts: 208
Joined: 12.08.2023 00:49

keys.json with CJK characters

Post by SamC »

Hello,
it seems the _json_loads method in cudax_lib.py will rasise error when the keys_json with CJK characters. Is there an option to set the decode to use cp936?
It happens with the macro plugin when read the keys.json
keys_js = apx._json_loads(open(keys_json).read()) if os.path.exists(keys_json) else {}
UnicodeDecodeError: 'gbk' codec can't decode byte 0xb0 in position 22826: illegal multibyte sequence
ERROR: Exception in CudaText for on_start: UnicodeDecodeError: 'gbk' codec can't decode byte 0xb0 in position 22826: illegal multibyte sequence
Thanks!
main Alexey
Posts: 2265
Joined: 25.08.2021 18:15

Re: keys.json with CJK characters

Post by main Alexey »

I made the fix for Macros, yet in the Github.
Download file
https://github.com/kvichans/cuda_macros ... _macros.py
and update it in the 'py/cuda_macros' folder. it helps?
SamC
Posts: 208
Joined: 12.08.2023 00:49

Re: keys.json with CJK characters

Post by SamC »

Code: Select all

Traceback (most recent call last):
  File "C:\Users\DELL\Desktop\cudatext\py\cuda_macros\cd_macros.py", line 82, in on_start
    self._do_acts(acts='|reg|menu|')
  File "C:\Users\DELL\Desktop\cudatext\py\cuda_macros\cd_macros.py", line 608, in _do_acts
    self.adapt_menu()
  File "C:\Users\DELL\Desktop\cudatext\py\cuda_macros\cd_macros.py", line 107, in adapt_menu
    , hotkey=get_hotkeys_desc(    'cuda_macros,dlg_config'))
  File "C:\Users\DELL\Desktop\cudatext\py\cuda_macros\cd_plug_lib.py", line 563, in get_hotkeys_desc
    keys_js     = apx._json_loads(open(keys_json).read()) if os.path.exists(keys_json) else {}
UnicodeDecodeError: 'gbk' codec can't decode byte 0xb0 in position 22826: illegal multibyte sequence
ERROR: Exception in CudaText for on_start: UnicodeDecodeError: 'gbk' codec can't decode byte 0xb0 in position 22826: illegal multibyte sequence
Init: cuda_project_man
Still exist errors,the full traceback is like above.
SamC
Posts: 208
Joined: 12.08.2023 00:49

Re: keys.json with CJK characters

Post by SamC »

I also add the encoding='utf8' in cd_plug_lib.py as you did for cd_macros.py,now it works~
Thanks~
main Alexey
Posts: 2265
Joined: 25.08.2021 18:15

Re: keys.json with CJK characters

Post by main Alexey »

Tks. Also the same problem (in the source) in ExtTools plugin. Will update both plugins soon.
Post Reply