It is currently March 28th, 2024, 10:38 am

Variable parsing difference

Report bugs with the Rainmeter application and suggest features.
Post Reply
User avatar
JelleDekkers
Posts: 127
Joined: September 27th, 2017, 6:32 pm
Location: Netherlands
Contact:

Variable parsing difference

Post by JelleDekkers »

So I was just casually writing a weather parser for Weather.com when I noticed something: languages with special characters (Hindi in this case) are written with Unicode character references instead of the characters themselves.

When trying to replace those references with the characters, the following happened:

"Normal" variable usage
Image

Nested variable usage
Image

Notice the output of the highlighted measure in the log. For some unknown reason, the "normal" way does not give me the desired result, but the nested approach does!
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Variable parsing difference

Post by Yincognito »

JelleDekkers wrote: October 28th, 2020, 1:58 pm So I was just casually writing a weather parser for Weather.com when I noticed something: languages with special characters (Hindi in this case) are written with Unicode character references instead of the characters themselves.

When trying to replace those references with the characters, the following happened:
[...]
Notice the output of the highlighted measure in the log. For some unknown reason, the "normal" way does not give me the desired result, but the nested approach does!
This (i.e. Unicode characters being written as \uNNNN in weather.com page source) is not unusual, and it has been discussed and solved actually (can't remember the exact thread and page). Just use the "new" DecodeCodePoints option in the child WebParser measures and it will work:
DecodeCodePoints.jpg
Indian Weather & Characters.jpg
As for the nested syntax, this is probably due to the fact that the nested variable is parsed in a dynamic way before being nested into the other variable, so the character references are replaced with the actual characters.
User avatar
JelleDekkers
Posts: 127
Joined: September 27th, 2017, 6:32 pm
Location: Netherlands
Contact:

Re: Variable parsing difference

Post by JelleDekkers »

I had no idea that option existed, but I'm not using the beta. It's still weird that this difference in ouput occurs.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Variable parsing difference

Post by Yincognito »

JelleDekkers wrote: October 28th, 2020, 3:45 pm I had no idea that option existed, but I'm not using the beta. It's still weird that this difference in ouput occurs.
It doesn't seem weird to me anymore, after better understanding the order in which things happen in Rainmeter and how the nested syntax works.
Post Reply