markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 10470: illegal multibyte sequence

Open highyield3011 opened this issue 1 year ago • 5 comments

(Microsoft-MarkItDown) C:\Users\zaish01317\MarkItDown>markitdown "C:\Users\zaish01317\translation-agent\examples\sample-texts\Modular RAG Transforming RAG Systems into LEGO-like Reconfigurable Frameworks.pdf"

"C:\Users\zaish01317\translation-agent\examples\sample-texts\Modular RAG Transforming RAG Systems into LEGO-like Reconfigurable Frameworks.pdf.md" Traceback (most recent call last): File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\lib\runpy.py", line 196, in _run_module_as_main return run_code(code, main_globals, None, File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\lib\runpy.py", line 86, in run_code exec(code, run_globals) File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\Scripts\markitdown.exe_main.py", line 7, in File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\lib\site-packages\markitdown_main.py", line 43, in main print(result.text_content) UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 10470: illegal multibyte sequence

(Microsoft-MarkItDown) C:\Users\zaish01317\MarkItDown>markitdown ModularRAG.pdf > ModularRAG.pdf.md Traceback (most recent call last): File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\lib\runpy.py", line 196, in _run_module_as_main return run_code(code, main_globals, None, File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\lib\runpy.py", line 86, in run_code exec(code, run_globals) File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\Scripts\markitdown.exe_main.py", line 7, in File "C:\Users\zaish01317.conda\envs\Microsoft-MarkItDown\lib\site-packages\markitdown_main.py", line 43, in main print(result.text_content) UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 10470: illegal multibyte sequence

ModularRAG.pdf

highyield3011 avatar Jan 15 '25 06:01 highyield3011

markitdown = MarkItDown()
result = markitdown.convert(read_filename)
with open('write_filename.md', 'w', encoding='gbk', errors='ignore') as f:
    f.write(result.text_content)

HArars avatar Jan 15 '25 16:01 HArars

Thank you @HArars

highyield3011 avatar Jan 16 '25 02:01 highyield3011

This works too:

>chcp 65001
Active code page: 65001

>set PYTHONIOENCODING=utf-8

>markitdown my_document.pdf > my_document.md

kristofmulier avatar Jan 18 '25 16:01 kristofmulier

This works too:

chcp 65001 Active code page: 65001

set PYTHONIOENCODING=utf-8

markitdown my_document.pdf > my_document.md

it seems does not work properly

LIMo927 avatar Jan 20 '25 03:01 LIMo927

The reported stdout encoding crash is addressed on main. For saved Markdown, please use markitdown input.pdf -o output.md (with your actual input filename). The -o option introduced in #116 writes UTF-8 directly and preserves characters that the terminal cannot represent; terminal output may replace unsupported characters.

Closing this encoding report as resolved. Please ask to reopen if the crash persists with the updated code, including your version and complete traceback.

afourney avatar Sep 05 '26 21:09 afourney