ssamko

File-save (encoding)

4 posts in this topic

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 !

Share this post


Link to post
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)

 

1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hmmm...it creates that file but without that encoding :/

EDIT: Got it... 

$h_file = FileOpen($BGIniFile, 129 ) ;utf-8
IniWrite($BGIniFile, 'General', 'Status','1')
FileClose($h_file)

 

Edited by ssamko

Share this post


Link to post
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",""))

 

Share this post


Link to post
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