It is currently December 10th, 2018, 8:54 pm

Rainmeter.ini is now UTF-16 LE (Unicode)

Changes made during the Rainmeter 4.2 beta cycle.
User avatar
jsmorley
Developer
Posts: 18445
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Rainmeter.ini is now UTF-16 LE (Unicode)

jsmorley » June 15th, 2018, 12:05 pm

We have changed the file encoding of Rainmeter.ini from ANSI to UTF-16 LE (Unicode). This addresses an issue with multi-byte Unicode characters being used in the path to skins, which would cause corruption of the associated [ConfigName] sections of Rainmeter.ini and would not allow config names with Unicode characters to load.

C:\Users\Jeffrey\Documents\Rainmeter\Skins\雨滴桌面\MySkin.ini

This also addresses a potential issue with the SkinPath option in Rainmeter.ini when the account name in Windows or the path to a portable installation uses multi-byte Unicode characters.

SkinPath=C:\Users\王芳\Documents\Rainmeter\Skins\

Any new Rainmeter installations will be UTF-16 LE by default, and any existing installations will be converted if needed when Rainmeter is started, or when existing Layouts or Layouts installed by a .rmskin are loaded.

Important note

This is going to have a minor backwards compatibility issue that we can't avoid. If you are using WebParser to "read" Rainmeter.ini, perhaps to check the "Active" status of a config, you will have to add CodePage=1200 to the parent WebParser measure to properly read the UTF-16 LE encoded file. If you are using Lua to read the file, you just won't be able to. You will have to read the entire file in with WebParser, and pass the result to Lua in order to do whatever value-added stuff you want.

If you are doing either of these things in a skin today, now would be the time to address this.

You may want to consider using the ConfigActive plugin to detect the active state of a skin, rather than trying to read Rainmeter.ini.

One other related note, you will NEVER be able to use [SomeText] with brackets in the path to Rainmeter skins. The [SomeText] construct is just fraught with meaning in Rainmeter, not the least of which is in Rainmeter.ini, and it can only lead to tears. Never, ever use that.
User avatar
raiguard
Posts: 493
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: Rainmeter.ini is now UTF-16 LE (Unicode)

raiguard » June 16th, 2018, 3:27 pm

So I’ve always been a stickler when it comes to file encoding, with me sticking to UTF-8 so I can do stuff with LUA and so the files play nicely with GitHub. Is ANSI still a proper, Rainmeter compatible alternative to UTF-16 LE (so GitHub will show commit changes to my skins without me having to insist on sticking with UTF-8)?

Also, skin loading. Currently I have great need to be able to know which variant in a config is loaded. The ConfigActive plugin doesn’t have support for this. Would it be possible to add support for this in the future?

If not, you mentioned that you can still use LUA to read a UTF-16 LE file if you pass it through WebParser. However, I have never been able to get WebParser to work as quickly or as consistently as I need it to be able to. It is simply too slow. I need to know which skins / config variants are loaded almost instantly, so I can set the stares of the toggle buttons used to load the skins. Perhaps I’m simply doing something wrong, could someone point me in the right direction as to how I could solve this problem?

Thanks in advance.
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
User avatar
jsmorley
Developer
Posts: 18445
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rainmeter.ini is now UTF-16 LE (Unicode)

jsmorley » June 16th, 2018, 3:49 pm

raiguard wrote:So I’ve always been a stickler when it comes to file encoding, with me sticking to UTF-8 so I can do stuff with LUA and so the files play nicely with GitHub. Is ANSI still a proper, Rainmeter compatible alternative to UTF-16 LE (so GitHub will show commit changes to my skins without me having to insist on sticking with UTF-8)?

Also, skin loading. Currently I have great need to be able to know which variant in a config is loaded. The ConfigActive plugin doesn’t have support for this. Would it be possible to add support for this in the future?

If not, you mentioned that you can still use LUA to read a UTF-16 LE file if you pass it through WebParser. However, I have never been able to get WebParser to work as quickly or as consistently as I need it to be able to. It is simply too slow. I need to know which skins / config variants are loaded almost instantly, so I can set the stares of the toggle buttons used to load the skins. Perhaps I’m simply doing something wrong, could someone point me in the right direction as to how I could solve this problem?

Thanks in advance.
1) How you encode your skin .ini files is up to you, Rainmeter is fine with ANSI, UTF-8 Without/BOM (as long as the file contains no characters outside the ASCII/Extended ASCII characters set), UTF-8 W/BOM (as long as the file contains no characters outside the ASCII/Extended ASCII characters set) , or UTF-16 LE. ANSI is really exactly the same as UTF-8 Without/BOM, as long as no Unicode characters are in the text.

I recommend UTF-16 LE, as having to remember to stay away from non-ASCII characters is a big pain, but to each his own. If you want to use ANSI / UTF-8 so they can be stored as text and not a binary on GitHub, that's up to you. What you can't do is encode it as UTF-8 and have any Unicode characters in it. GitHub may like that, Rainmeter will hate it.

Personally, I would not put that much stock in storing the skin .ini files on GitHub As UTF-8. Having them be UTF-16 LE seems to work fine for me. Maybe there is some impact on the "diff" on changes, I haven't explored it really. It is certainly fine doing "version control" with UTF-16 LE files.

2) As to Rainmeter.ini, there is just no way to read it with Lua directly. Lua simply will not deal with UTF-16 LE. You will have to read it with WebParser, using CodePage=1200, and have Lua get the result of that measure to deal with as you like. Rainmeter.ini must be encoded as UTF-16 LE, or it just causes problems for non-English users. Don't bother changing it on your system, we will just change it right back the next time Rainmeter is started.