xenodium / chatgpt-shell

A multi-llm Emacs shell (ChatGPT, Claude, Gemini) + editing integrations
https://xenodium.com
GNU General Public License v3.0
846 stars 75 forks source link

Explicitly specify UTF-8 encoding for temporary file in Windows #207

Closed shrubbroom closed 6 months ago

shrubbroom commented 6 months ago

The temporary buffer created in Windows with Chinese locale uses chinese-gbk-dos by default. The chatgpt may complain that there's an encoding issue since chinese characters encoded in chinese-gbk-dos and sent in UTF-8 will be transcoded into \uFFFD.

ChatGPT(4o/General)> 你好
It seems like there's an encoding issue with your message. Could you please clarify or rephrase your query?

ChatGPT(4o/General)> please send back the previous message and its unicode
Sure, here's your previous message along with its unicode representation:

### Original Message:
���

### Unicode Representation:
\uFFFD\uFFFD\uFFFD

It looks like the characters are not displaying correctly, which is why they appear as replacement characters (�). If you have a specific message or question, please try sending it again.

This patch explicitly specify UTF-8 as the encoding system of temporary buffer in Windows to avoid such issue. PTAL.