Jump to content

File-save (encoding)


 Share

Recommended Posts

Hello ! 

I have an .ini file for saving data from program. The main problem is that .ini uses ANSI encoding by default so it doesn't show special chars correctly. Is there a way I can use for save it with UTF-8 ? 

thnx !

Link to comment
Share on other sites

Create the .ini file manually with the correct encoding (before first write).

$h_file = FileOpen(@ScriptDir & "\data.ini", 2 + 1024) ; 1024 = UTF16-LE > initially create ini file in unicode format
FileWrite($h_file, "[Settings]" & @CRLF) ; you need to write something
FileClose($h_file)

 

Link to comment
Share on other sites

Upsa, 1024 seems to be the wrong mode :).

FileDelete(@ScriptDir & "\test.ini")
IniWrite(@ScriptDir & "\test.ini","test","test","有特殊需求再")
MsgBox(0,"",IniRead(@ScriptDir & "\test.ini","test","test",""))

FileDelete(@ScriptDir & "\test.ini")

$h_file = FileOpen(@ScriptDir & "\test.ini", 2 + 32) ; 32 = Use Unicode UTF16 Little Endian reading and writing mode.
FileWrite($h_file, "[test]" & @CRLF) ; you need to write something
FileClose($h_file)

IniWrite(@ScriptDir & "\test.ini","test","test","有特殊需求再")
MsgBox(0,"",IniRead(@ScriptDir & "\test.ini","test","test",""))

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...