I’m working with Delphi 7 application and BDE (legacy software).
whenever the password is changed/saved from ODBC admin
like this (example if the password was my,password )

It gets saved as my%2cpassword in the registry.

And my application reads the registry path
HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\mysource
Password
then uses the password to execute a psql command,
"C:\Program Files (x86)\PostgreSQL\9.0\bin\psql.exe" -h localhost -p 5432 -d myDB -U myadmin -f "C:\Users\user\AppData\Roaming\ff.sql"
Since the password now has %2c inside it instead of , the authentication fails.
As I read the password and write to the pgpass.conf file.
How to convert the Hex characters to proper string when the HEX character are mixed with normal character?
Since a % get’s encoded as %25 you should be able to pick them out of the string and change them back to their representative character.
To do this you’ll need to find % in the str using Pos/PosEx and pull out the 2 digits after it (I think it’s always 2)
This is off the top of my head, so apologies if it doesn’t compile/parameters are in the wrong order etc. It should be enough to give you the general idea.
To change hex to chr, swap the % for a $ and use
StrToIntwhich you can then use withCharorChrdepending on your preference.With these you should be able to scan through the string replacing the hex values