Unicode error, need to set default encoding
Opened this issue · 2 comments
bmann commented
And it worked. Thank you for sharing this code!
MaxGyver83 commented
I got a unicode error, too:
▶ python tiddly2md.py ../tiddlers.csv -o ../tiddlers_md
Traceback (most recent call last):
File "tiddly2md.py", line 121, in <module>
sys.exit(main(args))
File "tiddly2md.py", line 95, in main
filename = sanitize(row.title)
File "tiddly2md.py", line 76, in sanitize
value = unicode(value)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
This bugfix from the linked stackoverflow page fixed it for me:
▶ git diff 15:56:16
diff --git a/tiddly2md.py b/tiddly2md.py
index 0dc7a3d..02595d7 100644
--- a/tiddly2md.py
+++ b/tiddly2md.py
@@ -72,7 +72,7 @@ def sanitize(value):
:param value: string
"""
- value = unicode(value)
+ value = unicode(value, 'utf-8')
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip())
return value
MaxGyver83 commented
@achabotl : Thanks for sharing your converter script!