mattiasnordin / StataEditor

Stata Editor for Sublime Text 3
47 stars 18 forks source link

Encoding Problem when runing do files from Sublime #46

Closed po4dun closed 3 years ago

po4dun commented 3 years ago

Hi I have do files containing Umlautcharacters as "ä". When I open those do files in Stata do file editor as well as sublime, those chars are rendered nicely in both texteditors. However, when I send a query from Sublime to Stata (based on the same dofile), the Umlaute are not to be encoded correctly. I tried this with Stata 15 and 16, Sublime V 3.2.2 3211

Check this output from Stata:

When run from Sublime grafik .keep if cas_type=="station�r" (68,578 observations deleted)

When run from Stata do file editor grafik . keep if cas_type=="stationär" (55,330 observations deleted)

Sublime encoding config: "fallback_encoding": "Western (Windows 1252)", "default_encoding": "UTF-8"

Any ideas on how to solve this? Thanks a lot!

mattiasnordin commented 3 years ago

It's an encoding issue. My guess is that the do-file is saved with a different encoding than utf-8. Try "File -> Reopen with encoding" and choose "UTF-8". Does the file look correct? If not, then that is the issue. Either retype it with utf-8 or change the encoding in the settings.

po4dun commented 3 years ago

I investigated more: The File in Sublime looks almost always correct - no matter if I import it as UTF-8 or any other Western encoding. BUT if I open with "Western (Windows 1252)", then sublime shows weird characters instead of "ä". but if I send this code encoded in "Western (Windows 1252)" to Stata (whilst looking weird in Sublime), it arrives well in the form of "ä" in the stata output. If i then type an "ä" in Sublime into the same file still using the "Western (Windows 1252)" encoding, it looks correct in Sublime but after being sent to stata, those newly typed "ä" are looking weird in stata output.

I'm utterly confused by this behaviour. Does anyone have an idea?

po4dun commented 3 years ago

Hi I'm very sorry, but I know the solution now: I had a forked repository of stataeditor registered in Sublime - upon installation of your version, it goes smoothly now. I'm very sorry but thank you very much for your reply!

mattiasnordin commented 3 years ago

Great!