lsakizada Posted November 19, 2009 Posted November 19, 2009 (edited) Is there any way to read and write locale strings to/from INI files? I am interested about section names, keys and values Edited November 19, 2009 by lsakizada Be Green Now or Never (BGNN)!
water Posted November 19, 2009 Posted November 19, 2009 If I understand correctly you want to write/read special characters (Umlaut etc.)? I did a small test and everything seems to work fine: $sOut = "€öäüÖÄÜß" IniWrite("test.ini","Locale","Key",$sOut) $sIn = IniRead("test.ini","Locale","Key","NF") If $sOut = $sIn Then MsgBox(0,"","String is unchanged" & @CRLF & "Out: " & $sOut & @CRLF & "In: " & $sIn) Else MsgBox(0,"","String has changed" & @CRLF & "Out: " & $sOut & @CRLF & "In: " & $sIn) EndIf My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
lsakizada Posted November 19, 2009 Author Posted November 19, 2009 (edited) If I understand correctly you want to write/read special characters (Umlaut etc.)? I did a small test and everything seems to work fine: $sOut = "€öäüÖÄÜß" IniWrite("test.ini","Locale","Key",$sOut) $sIn = IniRead("test.ini","Locale","Key","NF") If $sOut = $sIn Then MsgBox(0,"","String is unchanged" & @CRLF & "Out: " & $sOut & @CRLF & "In: " & $sIn) Else MsgBox(0,"","String has changed" & @CRLF & "Out: " & $sOut & @CRLF & "In: " & $sIn) EndIf No I did not meant for that. Your code read locale string from Autoit script and not from ini file. I want to know if there are some function out there such as iniWriteUTF8, iniReadUTF8, iniReadSectionsUTF8, etc. So I could use them to store all info such as keys, values and section names in locales. EDIT: This did not work for me after setting SCITE to use UTF8 encoding Edited November 19, 2009 by lsakizada Be Green Now or Never (BGNN)!
water Posted November 19, 2009 Posted November 19, 2009 (edited) I see. I think what you want is not possible with pure AutoIt. Please see this post.But MrCreatoR seems to have written his own ini functions with UTF8 support (or see this post) Edited November 19, 2009 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
lsakizada Posted November 19, 2009 Author Posted November 19, 2009 I see. I think what you want is not possible with pure AutoIt. Please see this post. But MrCreatoR seems to have written his own ini functions with UTF8 support (or see this post) At this post MrCreator said that it is working with UTF8 I hope in the future it will be possible to IniWrite/Read in "UTF-8 with Signature" encoding (with UTF-8 itself works OK). Did i understood this note correctly? And why McCreator developed the following functions if it works with UTF8 I found the INIWriteEx() but not the INIReadEx...please whete it is? expandcollapse popup_IniWriteEx("C:\1.ini", "1", "1", "Đất nước Việt Nam", 128) Func _IniWriteEx($sIniFile, $sSection, $sKey, $sValue, $iUTFMode=0) If BitOR($iUTFMode, 16, 32, 64, 128) <> Number(16+32+64+128) Then $iUTFMode = 128 Local $sReadFile = FileRead($sIniFile) Local $hFile = FileOpen($sIniFile, 10+$iUTFMode) If $hFile = -1 Then Return IniWrite($sIniFile, $sSection, $sKey, $sValue) Local $aFileArr = StringSplit(StringStripCR($sReadFile), @LF) If @error Then If $sReadFile <> "" Then $sReadFile &= @LF FileWrite($hFile, $sReadFile & "[" & $sSection & "]" & @LF) FileWrite($hFile, $sKey & "=" & $sValue) FileClose($hFile) Return SetError(0, 0, 1) EndIf Local $sLF = @LF, $aSplitKeyValue, $iValueWasWritten = False For $i = 1 To $aFileArr[0] If $i = $aFileArr[0] Then $sLF = "" FileWrite($hFile, $aFileArr[$i] & $sLF) If $aFileArr[$i] = "[" & $sSection & "]" Then For $j = $i+1 To $aFileArr[0] If $j = $aFileArr[0] Then $sLF = "" If Not $iValueWasWritten Then If StringRegExp(StringRegExpReplace($aFileArr[$j], '\s+=', '='), $sKey & '=') Then $aSplitKeyValue = StringSplit($aFileArr[$j], "=") FileWrite($hFile, $aSplitKeyValue[1] & "=" & $sValue & $sLF) $iValueWasWritten = True ElseIf $aFileArr[$j] = "" Then FileWrite($hFile, $sKey & "=" & $sValue & $sLF) ElseIf StringLeft($aFileArr[$j], 1) = "[" Or $j = $aFileArr[0] Then FileWrite($hFile, $aFileArr[$j] & @LF & $sKey & "=" & $sValue & $sLF) Else FileWrite($hFile, $aFileArr[$j] & $sLF) EndIf Else FileWrite($hFile, $aFileArr[$j] & $sLF) EndIf Next ExitLoop ElseIf $i = $aFileArr[0] Then FileWrite($hFile, @LF & "[" & $sSection & "]" & @LF) FileWrite($hFile, $sKey & "=" & $sValue) EndIf Next FileClose($hFile) Return SetError(0, 0, 1) EndFunc Be Green Now or Never (BGNN)!
water Posted November 19, 2009 Posted November 19, 2009 Here you can find the complete UDF. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Tiotua Posted December 4, 2009 Posted December 4, 2009 In German I use this: #Include <String.au3> IniWrite("umlauts.ini", "Umlauts", "Example1", _StringToHex("Ich genieße öfter üblen Käse.")) $Result = _HexToString(IniRead("umlauts.ini", "Umlauts", "Example1", "")) msgbox(64,"Umlauts in INI", $Result) Exit Works perfectly. It should also work with Russian, Thai etc. chars. The only "handicap" is: you cannot read the values directly in the INI file.
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