jya-dev / supernote-tool

Unofficial python tool for Supernote
Apache License 2.0
237 stars 26 forks source link

conversion to text for all pages fails #32

Closed freshminty closed 12 months ago

freshminty commented 1 year ago

supernote-tool convert -t txt -a NoteFile OutputLocation works just fine, however, using -a like in the documentation fails supernote-tool convert -t txt -a NoteFile OutputLocation is the command that is failing and is straight from the examples in your readme

The error message I am getting is: Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\***\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts\supernote-tool.exe\__main__.py", line 7, in <module> File "C:\Users\***\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\supernotelib\cmds\supernote_tool.py", line 203, in main args.handler(args) File "C:\Users\***\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\supernotelib\cmds\supernote_tool.py", line 110, in subcommand_convert convert_and_concat_all(converter, total, args.output, save) File "C:\Users\***\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\supernotelib\cmds\supernote_tool.py", line 42, in convert_and_concat_all save_func('\n'.join(data), file_name) File "C:\Users\***\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\supernotelib\cmds\supernote_tool.py", line 106, in save f.write(data) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeEncodeError: 'charmap' codec can't encode character '\u2612' in position 1764: character maps to <undefined>

jya-dev commented 1 year ago

It seems encoding problem. The program handles text in UTF-8 internally, but the log shows using CP1252 encoding. I probably missed the encoding when saving the text. Do your note file include symbol (Unicode U+2612)?