ssamko Posted January 8, 2016 Posted January 8, 2016 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 !
KaFu Posted January 8, 2016 Posted January 8, 2016 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) ssamko 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
ssamko Posted January 8, 2016 Author Posted January 8, 2016 (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 January 8, 2016 by ssamko
KaFu Posted January 8, 2016 Posted January 8, 2016 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","")) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now