My native code page is 1251 (Cyrillic). When console code page is set to 1251 
(setConsoleOutputCP(1251)) output to console work just fine, but when print 
Cyrillic text with code page 65001 first two letter are broken. I made little 
investigation and find that write(f: File, c: cstring) works fine, but write(f: 
File, s: string) prints broken output. It is very interesting that cstring 
version uses c_fputc, but string version uses c_fwrite.

Little workaround: in file <NIMFOLDER>libsystemsysio.nim I changed proc 
write(f: File, s: string) (line 77): 
    
    
    proc write(f: File, s: string) = discard c_fputs(cstring(s), f)
    #  if writeBuffer(f, cstring(s), s.len) != s.len:
    #    raiseEIO("cannot write string to file")
    

Voila! all output now is perfect.

I like idea of default UTF-8 code page, frankly all nim strings are UTF-8... 
can we just throw away that fwrite?

Reply via email to