You are here

[Bug] KchmViewer Portable fails to load recent files having non-Latin characters in their paths

5 posts / 0 new
Last post
DabjeilQutwyngo
Offline
Last seen: 2 years 1 week ago
Joined: 2016-03-05 23:58
[Bug] KchmViewer Portable fails to load recent files having non-Latin characters in their paths

Here is the screenshot about what happens when recent files are opened from the File menu. The word “Английский” should be instead of the unprintable characters between words "Category" and "English".

Prior to open this issue, I have contacted the author of KchmViewer, and he pointed me to the KchmViewer's code where recent files are loaded from the paths passed. This code does not depend on the encoding of a file path. This code calls Qt's API that performs well with non-Latin characters, e.g., "Английский", at least on *nix platforms.

Then, I've checked what the Windows Registry's records contain. Here is the screenshot. The bug is highlighted with the red rectangle.

The issue is in that Qt's API writes data in Unicode (according to its source code). However, the Portable App environment writes then this data in ANSI instead of Unicode into the registry. When opening a recent file, the Portable App environment passes the wrong registry data to Qt’s API, which results in the fail presented in the first screenshot.

John T. Haller
John T. Haller's picture
Online
Last seen: 55 min 7 sec ago
AdminDeveloperModerator
Joined: 2005-11-28 22:21
Unicode

Kchmviewer Portable's launcher is Unicode only. Kchmviewer always used to store the recent files list - along with most of its other settings - as a reg_multi_sz which gets exported in an oddball hex format instead of standard strings. We wrote custom code to handle portablization of it that's used in the launcher. That code may either no longer be working or may fail on your specific paths. I'll mark this as a bug and investigate.

Sometimes, the impossible can become possible, if you're awesome!

3D1T0R
3D1T0R's picture
Offline
Last seen: 5 months 2 weeks ago
Developer
Joined: 2006-12-29 23:48
Registry::Read/Registry::Write assume ANSI

It seems that the same problem with Registry::Read is now rearing it's ugly head through Registry::Write.
REG_MULTI_SZ is apparently stored as Unicode in the registry, and instead of dealing with it as Unicode, Registry::Read/Write are treating it (as did we in the Custom Code we used to fix it for Registry::Read) as ANSI with a null character (which NSIS treats as a new line, hence how we wrote the old Custom Code) between each character.
With Registry::Read we were able to read it from the registry, take out the added, unnecessary characters, and write back to the registry, but as Registry::Write seems to assume the string is ANSI, and put null/newline ($\n) characters between any characters that don't already have it, which unintentionally puts them in the middle of Unicode characters, I don't see how we can work around this with Custom Code. This may have to wait till someone can fix NSIS' Registry plugin.
Sad

~3D1T0R

DabjeilQutwyngo
Offline
Last seen: 2 years 1 week ago
Joined: 2016-03-05 23:58
Reading REG_MULTI_SZ Values

Did you see the subj in the NSIS's documentation? KiCHiK wrote that script to read REG_MULTI_SZ values for one rpetges's task. The script is based on calling standard Win API RegOpenKeyExA.

To read Unicode values, KiCHiK recommended using RegOpenKeyEx instead of RegOpenKeyExA etc in the script. I suppose, the corresponding Win API should provide writing in the same manner.

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 1 hour 5 min ago
DeveloperModerator
Joined: 2008-07-24 18:46
Thanks

Thank you for finding this.

We'll need to confirm if the provided code works, and if so, make the change.

Log in or register to post comments