Jump to content

Help! IniWrite writing wrong character


oapjr
 Share

Go to solution Solved by BrewManNH,

Recommended Posts

Hi! I'm having problem with IniWrite function

The problem is that if the returned string from _FileListToArrayRec contain something like "3D-graphics1440x900" the string that is written on the ini file is "3D-graphics1440?900".

Does anyone know what I'm doing wrong?

Edit:

I know that if I rename the folder the functions work properly

#include <File.au3>

Local $iReturn
Local $sPath, $sFile
Local $aList

$sPath = @UserProfileDir & '\Pictures'
$iReturn = $FLTAR_FILES + $FLTAR_NOHIDDEN + $FLTAR_NOSYSTEM + $FLTAR_NOLINK
$aList = _FileListToArrayRec($sPath, "*jpg;*.png||", $iReturn, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
$sFile = $aList[Random(1, $aList[0], 1)]
IniWrite('test.ini','test','test',$sFile)
Edited by oapjr
Link to comment
Share on other sites

Where does that ini file come from, and could it be the case that that x is not a default letter x (plain old Ascii char 120) but some unicode character representing a mathematical multiplication symbol that just looks like an x? 

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

I believe, that what SadBunny says is correct. Your x is not a standard ASCII x, and is being substituted by a ? (question mark).

You need to code your own replacement.

It is possibly the extended ASCII character 215.

See the Appendix in the Help file.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I google the "х" from 1440х900 and I got this on Wikipedia:

 

Character Х х Unicode name CYRILLIC CAPITAL LETTER HA CYRILLIC SMALL LETTER HA Encodings decimal hex decimal hex Unicode 1061 U+0425 1093 U+0445 UTF-8 208 165 D0 A5 209 133 D1 85 Numeric character reference &#1061; &#x425; &#1093; &#x445; KOI8-R and KOI8-U 232 E8 200 C8 Code page 855 182 B6 181 B5 Code page 866 149 95 229 E5 Windows-1251 213 D5 245 F5 ISO-8859-5 197 C5 229 E5 Macintosh Cyrillic 149 95 245 F5

ps: the file contain a bunch of wallpaper I downloaded on the internet and the ini I created on autoit

Edited by oapjr
Link to comment
Share on other sites

  • Solution

By design, INI files are not Unicode aware. You can make your INI file able to save Unicode characters by doing a FileOpen using a Unicode file write mode, and then use FileClose to close it. Do this before using the INI file for the first time. See the Help file for IniWrite.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

By design, INI files are not Unicode aware. You can make your INI file able to save Unicode characters by doing a FileOpen using a Unicode file write mode, and then use FileClose to close it. Do this before using the INI file for the first time. See the Help file for IniWrite.

 

It worked! :D

Thank you everyone!

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...