Unicode characters in INI files

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Unicode characters in INI files

17 Oct 2023, 03:27

So some of the strings I write into .ini file are causing problems. Like the following string for example: "José_Luis"
How do I edit strings to remove or replace the offensive special characters?
just me
Posts: 9573
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Unicode characters in INI files

17 Oct 2023, 09:36

How do you create/update your INI file? (é looks like UTF-8)
PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Re: Unicode characters in INI files

17 Oct 2023, 10:20

just me wrote:
17 Oct 2023, 09:36
How do you create/update your INI file? (é looks like UTF-8)
It's extracted from clipboard.
Looks like Mike's link solves the problem. Will give it try.
PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Re: Unicode characters in INI files

17 Oct 2023, 16:16

So'kay guys. You all got it wrong because I presented the wrong problem.
As it turns out, with the following command: IniRead,temp,example.ini,section,%var% if var="", it dumps the entire section into the temp variable
:roll:
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Unicode characters in INI files

17 Oct 2023, 17:09

Yes, it is known that a section can be read when a key is not specified-- on the first page of the documentation about IniRead.
TAC109
Posts: 1129
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Unicode characters in INI files

17 Oct 2023, 17:46

Note that the documentation states that the contents of an INI file must either be ANSI or UTF-16. UTF-8 is not permitted.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: Unicode characters in INI files

18 Oct 2023, 11:03

just a basic example for iniread/write ( not answer to unicode )
( ahk script is saved with notepad as 'UTF-8 with BOM' , copied chinese characters to edit-field , content from INI-file was OK )

Code: Select all

#Warn
#NoEnv
SetWorkingDir %A_ScriptDir%
RSSINI=%A_scriptdir%\RSSINI.ini   ;- can also be a textfile xy.txt
;---------------------------------------
ifnotexist,%rssini%
    {
    IniWrite, Bocquet          , %rssini% ,A1   , KEY1
    IniWrite,José-Louis        , %rssini% ,A2   , KEY1
    IniWrite,+31-01-12345678   , %rssini% ,A3   , KEY1
    }
IniRead, A1, %rssini% , A1 , Key1
IniRead, A2, %rssini% , A2 , Key1
IniRead, A3, %rssini% , A3 , Key1
Gui,2: Add, text,  x10  y10 , Name
Gui,2: Add, text,  x10  y35 , Lastname
Gui,2: Add, text,  x10  y60 , Telephon
Gui,2: Add, Edit,  x100 y10 w100 vC1,%A1%
Gui,2: Add, Edit,  x100 y35 w100 vC2,%A2%
Gui,2: Add, Edit,  x100 y60 w100 vC3,%A3%
Gui,2: Add, Button,x100 y90  gSave,SAVE
Gui,2: Add, Button,x10  y90  gClear,CLEAR
Gui,2: Add, Button,x10  y120 gINIFile , Open-INI
Gui,2: Show,, NameList
send,^{end}
return
;---------------------------------------
2Guiclose:
exitapp
;---------------------------------------
Clear:
loop,3
  GuiControl,2:,C%a_index%,
return
;---------------------------------------
Save:
Gui,2: Submit,nohide
IniWrite, %C1%  , %rssini% ,A1   , KEY1
IniWrite, %C2%  , %rssini% ,A2   , KEY1
IniWrite, %C3%  , %rssini% ,A3   , KEY1
return
;---------------------------------------
INIFILE:
run,notepad "%rssini%"
return
;=======================================

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, Descolada, fiaztv1 and 227 guests