- NSIS Discussion
- Unicode Nsis - Problem reading a xml file
Archive: Unicode Nsis - Problem reading a xml file
bennaloz
11th January 2012 12:37 UTC
Unicode Nsis - Problem reading a xml file
Hi all.
I am trying to build a unicode setup. I have to read some informations from a xml file but in the unicode version i can not do it. I tried to use different plugins like XML plugin(the one i used for the ANSI setup and it works fine), nsisXml and some others. with XML plugin in the unicode version I retrieve instead of my values, other chars(like squares <.< or empty strings). I can't understand why this happend. Xml plugin could support unicode UTF-8.
I attach the code I am using for reading the xml file and the xml file.
<root>
<version vers="myvalue"/>
</root>
${If} ${FileExists} "file.xml"
${xml::LoadFile} "file.xml" $0
${xml::FindNextElement} "version" $0 $1
${xml::ElementPath} $Path
${xml::GotoPath} "$Path" $5
${xml::GetAttribute} "vers" $myvar $2
${xml::Unload}
${EndIf}
I can not understand why this code work in ANSI format returning in this example "myvalue" and does not work in UTF-8 returning a square or an empty string:hang::(.
p.s. I am sorry for my English .-. and i can not find the answer in other threads so i made this...:p
Thnx in advance
Bennaloz
T.Slappy
12th January 2012 05:44 UTC
Please clarify which parts are unicode and which not!
If you have UNICODE NSIS you need to have UNICODE plugins (xml plugin)
But the .XML file still may be saved as NON-unicode!
Reading ANSI xml file with Unicode plug-in will be probably fine but reading UTF-8 xml file
may fail even with Unicode plug-in.
bennaloz
12th January 2012 07:37 UTC
Ok for first I am sorry if I am making a stupid question or asking the obvious but I am a beginner in this field and I still don't know how things work. I will try to explain you better what the situation is.
I am using Notepad++ as text editor. I made my non-Unicode setup so in ANSI format. But since I need an Unicode one I thought to convert it in UTF-8 with notepad but compiling it with Unicode NSIS it does not work.
Initially I didn't think about the format of the .xml file but then I tried to convert it to UTF-8 and it didn't work the same so I tried again to ANSI format and the result was the same, I can't read the .xml file.
I am using the XML plugin(nsis.sourceforge.net/XML_plug-in <-- this one) that should support Unicode UTF-8.
I don't understand why I can't read the .xml file.
I hope I was clear explaining the problem.
Thnx again
Yathosho
12th January 2012 09:01 UTC
you don't have to convert the script to unicode, the unicode compiler does this for you. however, you might have to convert your xml file to unicode to make it work with your unicode installer. a2u.exe should do the job!
bennaloz
12th January 2012 10:58 UTC
Ok T.Slappy said the opposite that is "Reading ANSI xml file with Unicode plug-in will be probably fine but reading UTF-8 xml file
may fail even with Unicode plug-in. "
(And then I was thinking about that a unicode setup should be able to read an ansi and a unicode file because unicode includes also ansi chars if I am not wrong.)
Anyway right now I have no ideas what to do.
If I have to read a .xml file (ansi or unicode) with a unicode setup how can I do it? If I have to convert it to unicode from ansi I was trying Unicode plugin(because I need to convert it runtime) but it seems can't open the file and I don't know why.
bennaloz
12th January 2012 12:15 UTC
I have just made a new setup. I tried only to load a .xml file that doesn't exist. The return should be a -1 because it doesn't exist but returned a square. So what is the problem? This plugin doesn't support unicode?
Afrow UK
12th January 2012 13:06 UTC
Have you extracted the Unicode version of the plug-in (if there is one)?
Stu
bennaloz
12th January 2012 13:30 UTC
There is only a .dll file and a .nsh file (related .dll library) (nsis.sourceforge.net/XML_plug-in) this is the plugin I am using... I see the square compiling with unicode NSIS and showing the result with detailPrint or messageBox I don't think that the reason of the square is the way that I show the result. Anyway there is only a plugin in the pack and on sourceforge is write it support unicode UTF-8.
I attached my source. Try to compile it with both NSIS unicode and ansi and you will see the difference. Obviously you must have my xml plugin you find it in the link above. let me know what's wrong if you can.
Afrow UK
12th January 2012 14:50 UTC
If you want to use a plug-in with Unicode NSIS you will usually need a Unicode build of that plug-in.
Stu
bennaloz
12th January 2012 14:53 UTC
ah yes sure... So do you know some unicode plug-ins to read xml? i'll repeat that this one should be unicode anyway if you know others plugin please tell me maybe one that works...
Afrow UK
12th January 2012 16:09 UTC
http://wiz0u.free.fr/prog/nsisXML/
Stu
bennaloz
13th January 2012 07:11 UTC
tested... it gives me a Runtime error when I execute the unicode setup... also using the examples... so it's not a my mistake writing the source... but other problems and I don't know what kind of problems could be
Can I ask someone to make a little example that works and read a .xml file(maybe with wizou's plugin)? Could the OS be the cause of the problem? (I don't think I am using XP)
bennaloz
13th January 2012 09:57 UTC
OK I am noob I make it works now...@afro Thnx for the link you said it works and it works I said that it didn't work because before installing unicode nsis I took only the ansi plugin... anyway thnx for all...
bennaloz
13th January 2012 12:58 UTC
Anybody know if NsisList plug-in support unicode?
ok never mind I solved by myself
Afrow UK
13th January 2012 14:54 UTC
There doesn't appear to be a Unicode build. Did you use a different plug-in instead?
Stu
bennaloz
16th January 2012 07:36 UTC
Yes I used nsArray. If I am not wrong you made it.
Afrow UK
16th January 2012 12:47 UTC
Correct :)
Stu
bennaloz
16th January 2012 16:01 UTC
At last it's a list managed like an array right? or not? u.u
Afrow UK
16th January 2012 21:07 UTC
Yes it uses a linked list of pointers rather than a large allocation of contiguous memory.
Stu
bennaloz
17th January 2012 07:08 UTC
yes because otherwise it would be impossible to add/delete elements. anyway thanks a lot again for the help...