Jump to content

iniread with accents (non English strings) - (Moved)


Go to solution Solved by SOLVE-SMART,

Recommended Posts

Posted

I have a script that uses GUIs and iniread to create labels in given languages, French, German and Korean for example.

I have just realised that after the update to 3.3.16.0 the script no longer reads non English strings correctly.

This GUI image.png.70d859eb778da027a46d3d4fa1c513d5.png

used to show as as Mettre à jour and Masquer la fênetre.

Is there a way of correcting this with an option or something?

Posted

I tried running a program compiled before I updated to 3.3.16.0 and that read the inifile correctly with the accents. However I went back to 3.3.14.2 which is the version I was using and restarted my computer and it still shows as above.

  • Moderators
Posted

Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

try when you put this lines in your SciTEUser.properties

code.page=65001
output.code.page=65001
NewFileEncoding=UTF8
utf8.auto.check=4

and restart SciTE

Edited by ioa747

I know that I know nothing

  • Solution
Posted (edited)

Hi @Graeme,

I assume (I understood) you already have one or more ini files that don't show for example german "umlauts" correct in the GUI. In this case you can simple rewrite the ini file to "UTF-16 LE" which will display the correct umlauts in the GUI.

Try these test data:

[SectionOne]
KeyOne = Default text
KeyTwo = German umlaut ÄäÜüÖöß

Create a ini file (ini-read-test.ini) and save this example content (as UTF-8 which should be the default encoding for SciTE or VSCode). Then run the following script:

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#AutoIt3Wrapper_UseUpx=n
#Au3Stripper_Parameters=/sf /sv /mo /rm /rsln

_Actions()

Func _Actions()
    Local Const $sIniFile = @ScriptDir & '\ini-read-test.ini'

    ;~ _RewriteIniFileToUtf16LittleEndian($sIniFile) ; You just have to use that ini rewrite one time, that's it.

    Local Const $sValueOne = IniRead($sIniFile, 'SectionOne', 'KeyOne', '')
    Local Const $sValueTwo = IniRead($sIniFile, 'SectionOne', 'KeyTwo', '')
    Local Const $hGui      = _CreateGui($sValueOne, $sValueTwo)

    _GuiEventListener()
    _DisposeAndExit($hGui)
EndFunc

Func _RewriteIniFileToUtf16LittleEndian($sFile)
    Local Const $iReadWithUtf8NoBom          = 256
    Local Const $iWriteWithUtf16LittleEndian = 32 + 2

    Local $hFile = FileOpen($sFile, $iReadWithUtf8NoBom)
    Local Const $sFileContent = FileRead($hFile)
    FileClose($hFile)

    $hFile = FileOpen($sFile, $iWriteWithUtf16LittleEndian)
    FileWrite($hFile, $sFileContent)
    FileClose($hFile)
EndFunc

Func _CreateGui($sLabelTextOne, $sLabelTextTwo)
    Local Const $hGui = GUICreate('ini-read-test')

    GUICtrlCreateLabel($sLabelTextOne, 15, 15)
    GUICtrlCreateLabel($sLabelTextTwo, 15, 50)
    GUISetState(@SW_SHOW, $hGui)

    Return $hGui
EndFunc

Func _GuiEventListener()
    Local Const $iGuiCloseEventFlag = -3

    While True
        Switch GUIGetMsg()
            Case $iGuiCloseEventFlag
                ExitLoop
        EndSwitch
    WEnd
EndFunc

Func _DisposeAndExit($hGui)
    GUIDelete($hGui)
    Exit
EndFunc

💡 First run should display the incorrect version of the german umlauts. Please activate line 12 _RewriteIniFileToUtf16LittleEndian() and run again. Now your ini is rewritten an the GUI displays the correct characters.

Conclusion: Open your ini file(s) and rewrite them as "UTF-16 LE" (_RewriteIniFileToUtf16LittleEndian($sIniFile)) one time and you can use your script/program like before (I hope 🤞😀).

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 AutoIt Cheat Sheet

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

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
  • Recently Browsing   0 members

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