AIStoryWriter icon indicating copy to clipboard operation
AIStoryWriter copied to clipboard

Writing files in Windows crashes on certain unicode characters in cp1252 files. Specify utf-8 encoding when opening files.

Open chipfox opened this issue 11 months ago • 2 comments

The SaveLangchain function in PrintUtils.py writes MarkdownVersion to a file. The default encoding for file writing on Windows is cp1252, which doesn't support many Unicode characters and will sometimes cause a crash.

All lines that open files need to be specified as utf-8 like this: with open(ThisLogPathJSON, "w", encoding="utf-8") as f: with open(ThisLogPathMD, "w", encoding="utf-8") as f: with open(f"{self.LogDirPrefix}/Story.md", "w", encoding="utf-8") as f:

https://github.com/datacrystals/AIStoryWriter/blob/25d675377e82f0bd0308ed630ebf25b2b7b41e16/Writer/PrintUtils.py#L41-L58

chipfox avatar Jan 11 '25 21:01 chipfox

Same here Also need to change Write.py:248

with open(Args.Prompt, "r", encoding="utf-8") as f:

StevenLi-phoenix avatar Jun 29 '25 05:06 StevenLi-phoenix

addressed by #76

richard087 avatar Nov 28 '25 00:11 richard087