Commit 72c2934
committed
fix: Handle UnicodeDecodeError in PlainTextConverter (microsoft#1505)
When charset detection samples only the first 4096 bytes and detects 'ascii',
but the file contains UTF-8 characters beyond that point,
decoding fails with UnicodeDecodeError.
Added fallback to charset_normalizer when UnicodeDecodeError occurs,
allowing proper handling of files with non-ASCII characters
(Spanish, Korean, Japanese, Chinese, etc.)
that appear after the 4096-byte sample.
Cherry-picked from microsoft/markitdown PR microsoft#15401 parent 7fdaefb commit 72c2934
2 files changed
Lines changed: 55 additions & 2 deletions
File tree
- packages/markitdown
- src/markitdown/converters
- tests
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
66 | 68 | | |
67 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
68 | 75 | | |
69 | | - | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
459 | 504 | | |
460 | 505 | | |
461 | 506 | | |
| |||
495 | 540 | | |
496 | 541 | | |
497 | 542 | | |
| 543 | + | |
498 | 544 | | |
499 | 545 | | |
500 | 546 | | |
| |||
0 commit comments