Jump to content

Can't read section names which contains Turkish characters


ahmetpi
 Share

Recommended Posts

Hi,

I have an ini file which contains special Turkish characters like ş, Ö, İ, ı....

Example ini:

[İnkılap]
key=value

[Türkçe]
key=value

Example code:

$var1="İnkılap"

$var2 = IniReadSection(".....inifilepath\example.ini", $var1)

MsgBox(0, "Example", $var2 =)

It returns nothing. So, how can i fix this? I am kinda noob so if you can give me an example code, i would be very glad

Link to comment
Share on other sites

Selam,

Your usage seems to be wrong?

The return from inireadsection is an array

The number of elements returned will be in $aArray[0][0]. If an @error occurs, no array is created.
    $aArray[0][0] = Number
    $aArray[1][0] = 1st Key
    $aArray[1][1] = 1st Value
    $aArray[2][0] = 2nd Key
    $aArray[2][1] = 2nd Value

 

Try:

msgbox(0,"Example", $var2[1][0] & " - " & $var2[1][1])

Link to comment
Share on other sites

3 minutes ago, GokAy said:

Selam,

Your usage seems to be wrong?

The return from inireadsection is an array

The number of elements returned will be in $aArray[0][0]. If an @error occurs, no array is created.
    $aArray[0][0] = Number
    $aArray[1][0] = 1st Key
    $aArray[1][1] = 1st Value
    $aArray[2][0] = 2nd Key
    $aArray[2][1] = 2nd Value

 

Try:

msgbox(0,"Example", $var2[1][0] & " - " & $var2[1][1])

Selam abi, çok teşekkürler cevapladığın için İngilizce bilgim çok iyi değil o yüzden Türkçe yazayım en iyisi
Dediğiniz doğru IniReadSection'u yanlış kullanmışım ancak onu düzeltsem bile içinde Türkçe karakter olan section'ları getirmiyor nedense.

Bu section name'leri bir input ile ini dosyasına kayıt ediyorum o input kısmında türkçe karakterleri elemem filan mümkün mü acaba? Belki o şekilde yapabilirim diye düşündüm ben

Link to comment
Share on other sites

If you save your ini file with UTF-16LE with BOM encoding, it handles Turkish characters.

#include <Constants.au3>
#include <Debug.au3>


example()

Func example()
    Local $aIniSection

    $aIniSection = IniReadSection("test.ini", "Türkçe")
    If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "IniReadSection failed - @error = " & @error)

    _DebugArrayDisplay($aIniSection, "Türkçe Section")

    MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "Türkçe", "Key = " & IniRead("test.ini", "Türkçe", "Key", "Not Found"))
EndFunc

image.png.8caf3bea07f971da599e2b797c26f8d0.png

image.png.bfb1e8645deb6244d71935c158c95adb.png

Edited by TheXman
Link to comment
Share on other sites

The console will not display it correctly.  Try MsgBox.

image.png.131fc9d35646c9f6321e2be61184f21a.png

Edited by TheXman
Link to comment
Share on other sites

  • 3 months later...
On 12/12/2020 at 5:55 PM, TheXman said:

If you save your ini file with UTF-16LE with BOM encoding, it handles Turkish characters.

#include <Constants.au3>
#include <Debug.au3>


example()

Func example()
    Local $aIniSection

    $aIniSection = IniReadSection("test.ini", "Türkçe")
    If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "IniReadSection failed - @error = " & @error)

    _DebugArrayDisplay($aIniSection, "Türkçe Section")

    MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "Türkçe", "Key = " & IniRead("test.ini", "Türkçe", "Key", "Not Found"))
EndFunc

image.png.8caf3bea07f971da599e2b797c26f8d0.png

image.png.bfb1e8645deb6244d71935c158c95adb.png

Hi again, 

How can i save ini file with UTF16-LE ? I cant find on text editor

EDİT :  I solved with sublime text editor, thanks again

Edited by ahmetpi
Solved
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...