Character Encoding in Rainmeter (updated)

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar

Character Encoding in Rainmeter (updated)

September 18th, 2013, 6:37 pm
jsmorley
Developer   [15701 posts]

Given the international audience of Rainmeter, one of the things that comes up regularly is how to use and display non-ASCII character sets in skins. The following guide explains how to use Unicode with Rainmeter skins, WebParser and Lua.

Unicode in Rainmeter
User avatar

Re: Character Encoding in Rainmeter (updated)

July 13th, 2015, 1:04 am
exper1mental
   [282 posts]

Hmm... I seem to be having trouble getting this to work. In Sublime I have the my skin as UTF-16 LE but it still doesn't display the correct characters for my WiFi's Russian SSID.


What am I doing wrong? Does the WifiStatus plugin not have full character support?

Thanks
User avatar

Re: Character Encoding in Rainmeter (updated)

July 13th, 2015, 2:04 am
jsmorley
Developer   [15701 posts]

It may well not. It almost has to be the plugin, as Rainmeter is just always UTF-16 Unicode, and it really doesn't matter how you have the .ini encoded. That is only important if you are actually putting Unicode characters into the .ini yourself.

Hopefully someone can look into the plugin, but in the meantime, can you try this skin and let us know what you get?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureGetSSID "Run"]

[MeasureGetSSID]
Measure=Plugin
Plugin=RunCommand
Parameter=netsh wlan show all
OutputType=Ansi
RegExpSubstitute=1
Substitute="(?siU)^.*= SHOW INTERFACES =.* State.*: connected.* SSID.*: (.*)\n.*$":"\1","#CRLF#":""

[MeterSSID]
Meter=String
MeasureName=MeasureGetSSID
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=SSID: %1


The RunCommand plugin is here in case you don't already have it installed:
http://rainmeter.net/forum/viewtopic.php?p=92974#p92974

This works for me, but it remains to be seen how it handles the character set.

If it fails, try this command from the cmd.exe command prompt, and paste in what you get there, so we can look at that.

netsh wlan show all
User avatar

Re: Character Encoding in Rainmeter (updated)

July 13th, 2015, 11:44 am
exper1mental
   [282 posts]

jsmorley wrote:It may well not. It almost has to be the plugin, as Rainmeter is just always UTF-16 Unicode, and it really doesn't matter how you have the .ini encoded. That is only important if you are actually putting Unicode characters into the .ini yourself.

Hopefully someone can look into the plugin, but in the meantime, can you try this skin and let us know what you get?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureGetSSID "Run"]

[MeasureGetSSID]
Measure=Plugin
Plugin=RunCommand
Parameter=netsh wlan show all
OutputType=Ansi
RegExpSubstitute=1
Substitute="(?siU)^.*= SHOW INTERFACES =.* State.*: connected.* SSID.*: (.*)\n.*$":"\1","#CRLF#":""

[MeterSSID]
Meter=String
MeasureName=MeasureGetSSID
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=SSID: %1


The RunCommand plugin is here in case you don't already have it installed:
http://rainmeter.net/forum/viewtopic.php?p=92974#p92974

This works for me, but it remains to be seen how it handles the character set.

If it fails, try this command from the cmd.exe command prompt, and paste in what you get there, so we can look at that.

netsh wlan show all

This is what I'm getting:

I also tried some of the suggestions from this Superfollow post to get them to display correctly in the command prompt, without success.

In case it is relevant the WiFi actually an iPhone hotspot.
User avatar

Re: Character Encoding in Rainmeter (updated)

July 13th, 2015, 11:56 am
jsmorley
Developer   [15701 posts]

I'm just not sure. We looked at the WifiStatus code, and that all seems ok. I'm sure you are far from the first person to have a router SSID that isn't just ASCII characters, so if there was a fundamental problem I would expect that this would have come up a ton of times before.

It may be related to the standard that only allows 32 bytes in an SSID, and unicode may cause issues with that.

Most of what I have seen around the web seems to suggest that using unicode in an SSID is not a great idea, as it can have cross-platform issues.

Just for fun, could you try OutputType=Utf8 in the RunCommand measure? I'm wondering if the output isn't really Utf8, and not Ansi or Utf16.
User avatar

Re: Character Encoding in Rainmeter (updated)

July 13th, 2015, 1:59 pm
exper1mental
   [282 posts]

jsmorley wrote:I'm just not sure. We looked at the WifiStatus code, and that all seems ok. I'm sure you are far from the first person to have a router SSID that isn't just ASCII characters, so if there was a fundamental problem I would expect that this would have come up a ton of times before.

It may be related to the standard that only allows 32 bytes in an SSID, and unicode may cause issues with that.

Most of what I have seen around the web seems to suggest that using unicode in an SSID is not a great idea, as it can have cross-platform issues.

Just for fun, could you try OutputType=Utf8 in the RunCommand measure? I'm wondering if the output isn't really Utf8, and not Ansi or Utf16.

Actually I already tried that but forgot to mention it or post the screenshots.
Unicode3.png

UTF16:


I wonder if it might work better on Windows 10...

In the process of trying to get my WiFi SSID to display correctly I've learned:
- We can use emoticons and emoji smileys for WiFi names... [LINK]
- If my neighbor is stealing WiFi I can supposedly flip all their images upside down :sly: [LINK]
- How to get completely distracted by Reddit WiFi names and Kittenwar

Back on topic, the thing that confuses me is why only Command Prompt and Rainmeter plugins cannot display the SSID properly. Does WiFiStatus get the SSID from the Command Prompt like RunCommand does? Would the issue in Command Prompt be caused by my system language and non-Unicode program language being English?
User avatar

Re: Character Encoding in Rainmeter (updated)

July 13th, 2015, 2:07 pm
jsmorley
Developer   [15701 posts]

I am stumped. We need someone else that has a router SSID with Russian characters to test the WiFiStatus plugin. I'm not sure if the iPhone hotspot thing is playing a role, but I'd like to eliminate that from the mix.
User avatar

Re: Character Encoding in Rainmeter (updated)

February 26th, 2016, 9:35 pm
~Faradey~
   [348 posts]

recently i stumbled on same issue...(about RunCommand)

The thing is that plugin show output of IBM 866 encodings as ASCII1251 without converting as i can tell, that is why some characters looks like
gibberish. I've wrote function and tried to convert string using lua but it failed. I can't get to understand which ASCII encoding it uses string.byte, when i put code for any non latin letter /sign lua returns 'unidentified sign' symbol...oh well... Substitute for the rescue :)
User avatar

Re: Character Encoding in Rainmeter (updated)

February 27th, 2016, 11:44 am
~Faradey~
   [348 posts]

Ok i've done some testing and now i have answer and solution

My decoding function didn't work because of lua script file was saved in UTF-16 (USC-2 Little Endian), but if i save it in ANSI it would work as intended. Maybe this is Rainmeter related thing why it didn't work any else way.

Anyway here is a solution
use lua script to convert gibberish string like in this subgect. I use it to convert output from RunCommand plugin :)

if you are going to use it as part of your script or as singe script in any case - file encoding must be ANSI

Code: Select all

function _Encoding_866To1251(str)
   local sResult = ""
   local ic
   Var866Arr = {}
   
   for c in str:gmatch(".") do
      table.insert(Var866Arr, c)
   end
   
   for i = 1, #Var866Arr do
      ic = string.byte(Var866Arr[i])

      if ic >= 128 and ic <= 175 then
         Var866Arr[i] = string.char(ic + 64)
      elseif ic >= 224 and ic <= 239 then
         Var866Arr[i] = string.char(ic + 16)
      elseif ic == 240 then
         Var866Arr[i] = string.char(168)
      elseif ic == 241 then
         Var866Arr[i] = string.char(184)
      elseif ic == 252 then
         Var866Arr[i] = string.char(185)
      end

      sResult = sResult..Var866Arr[i]
   end

   return sResult
end -- func


if some of you having troubles of how to use it, let the forums know about it

Return to “Featured Guides”



Who is online

Users browsing this forum: No registered users and 0 guests