It is currently April 25th, 2024, 1:16 pm

Convert lowercase to uppercase

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Convert lowercase to uppercase

Post by jsmorley »

balala wrote::thumbup: I think there is no (good) solution for this?
Nothing that will let you have your cake and allow you to eat it as well. You either have to convert to upper case and use string.gsub() which doesn't care about the byte-width of characters, or use my first approach which will maintain the string case as is, but will likely fail on Unicode in the @Resources path.

Lua is fine with Unicode, with the exception of any functions that depend on string "length" or character "position". A single mutli-byte Unicode character is seen as two characters by Lua. Lua lives in an 8-bit world...
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert lowercase to uppercase

Post by balala »

jsmorley wrote:if you store the path variables in the .inc file in upper case, it will work fine, unless you are "displaying" the path in the skin, in which case converting to upper case might not look great.
Yes, but still will work.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert lowercase to uppercase

Post by balala »

jsmorley wrote:Lua lives in an 8-bit world...
8-bit? Didn't evolve?
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert lowercase to uppercase

Post by balala »

And finally it seems I found the solution, even without using a lua script.
The idea is to use jsmorley's very simple substitution. But that substitution doesn't work, due to the reserved characters, contained into the path of the file (the Path variable). So, I thought I should have to replace the \ characters to something not reserved (like -), then make jsmorley's substitution (Substitute="(?i)#@#":"#*@*#") and finally convert back the eventually remaining - characters, to \:

Code: Select all

[Rainmeter]
Update=-1

[Variables]
Path=

[MeasureString]
Measure=String
String=#Path#
Substitute="\":"-"

[MeasureResources]
Measure=String
String=#@#
Substitute="\":"-"

[MeasureString2]
Measure=String
String=[MeasureString]
RegExpSubstitute=1
Substitute="(?i)[MeasureResources]":"#*@*#","-":"\"
jsmorley (or/and obviously anyone else), could you please test this solution, to see if it works for you as well? You have to add the Path variable, which I didn't post. [MeasureString2] should have to return the path given by the Path variable, appropriately (using or not using the #@# variable, depending on what path did you give).
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Convert lowercase to uppercase

Post by jsmorley »

Seems ok. I would probably not use a character like "-" that is valid in a path or file name, but maybe "!" which isn't. Just be sure whatever you use isn't a reserved character in regular expression.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert lowercase to uppercase

Post by balala »

jsmorley wrote:Seems ok. I would probably not use a character like "-" that is valid in a path or file name, but maybe "!" which isn't. Just be sure whatever you use isn't a reserved character in regular expression.
Yes, you're right, however the exclamation mark (!) is a valid character in file names. But this is just a small detail, I'll find something to use. The question was if this approach works. Thanks for testing it.

And one more big thanks for all the help. Your replies was extremely useful, I wouldn't got it to work, without your help. So, thank again...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Convert lowercase to uppercase

Post by jsmorley »

Perhaps "]]". "]" is not reserved in PCRE regular expression, and while I suppose possible in a path, the double close brackets is certainly not likely. Note that "[" IS reserved.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert lowercase to uppercase

Post by balala »

jsmorley wrote:Perhaps "]]". "]" is not reserved in PCRE regular expression, and while I suppose possible in a path, the double close brackets is certainly not likely. Note that "[" IS reserved.
Yes, I also thought to something longer than one single character. Will have to test it later, but I think "]]" is a good idea. Thanks again.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Convert lowercase to uppercase

Post by jsmorley »

balala wrote:Yes, I also thought to something longer than one single character. Will have to test it later, but I think "]]" is a good idea. Thanks again.
Actually, I think ">" or "<" will do. Those are not reserved in regular expression, and not allowed in Windows path or file names, since in DOS they mean "redirect".

You must stay away from [ \ ^ $ . | ? * + ( )
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert lowercase to uppercase

Post by balala »

jsmorley wrote:Actually, I think ">" or "<" will do. Those are not reserved in regular expression, and not allowed in Windows path or file names, since in DOS they mean "redirect".

You must stay away from [ \ ^ $ . | ? * + ( )
Yes, probably ">" and "<" are good ideas.
About the reserved characters, are the "{" and "}" also reserved, beside those listed by you?