[Solved] If var is upper/lower with international characters

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Okram
Posts: 24
Joined: 02 Oct 2013, 16:53

[Solved] If var is upper/lower with international characters

19 May 2016, 13:05

I need to recognize upper/lower case of a string. I tried If var is upper but it does not recognize international characters. Is there any other way?

Code: Select all

var:="Д"
if var is upper
	msgbox UPPER  ;doesn't work
Last edited by Okram on 20 May 2016, 11:46, edited 1 time in total.
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: If var is upper/lower with international characters

19 May 2016, 13:31

this worked for me

Code: Select all

var:="Д"
StringLower, lower, var
if !(var==lower)
	MsgBox Upper
Okram
Posts: 24
Joined: 02 Oct 2013, 16:53

Re: If var is upper/lower with international characters

19 May 2016, 14:42

Thanks, however my example was misleading - I need to check the longer string, not just one character. Are all characters in the string Upper case?
Like;

Code: Select all

var:="ДОБРО"
if var is upper
	msgbox Upper
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: If var is upper/lower with international characters

20 May 2016, 01:50

Code: Select all

Russian := "ДОБРО"
Loop, Parse, Russian
{
	StringLower, Lower, A_LoopField
	Result .= A_LoopField " : " ( A_LoopField == Lower ? "Lower":"Upper" ) "`n"
}
Msgbox % Result
If you have an answer, please check it as [Solved] in you title.


(PS:
His code was right. "True if var is empty or contains only lowercase characters. False if there are any digits, spaces, tabs, punctuation, or other non-lowercase characters anywhere in the string.")
Last edited by IMEime on 20 May 2016, 07:13, edited 1 time in total.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: If var is upper/lower with international characters

20 May 2016, 03:46

Slightly changing AlphaBravo's code makes a simpler solution.

Code: Select all

var:="ДОБРО"
varl:="добро"
stringUpper,upper,var ; change to varl if you want to ensure it correctly capitalizes (it does)
if(var==upper)
    msgbox Upper
if !(varl==upper)
    msgbox Lower
msgbox % var "`n" varl "`n" upper
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
Okram
Posts: 24
Joined: 02 Oct 2013, 16:53

Re: If var is upper/lower with international characters

20 May 2016, 07:39

Thanks to all for responding. AlphaBravo's code recognizes a string including any one upper case character like доБро as Upper.

I need to recognize if a string is in ALL CAPS. I guess the only way is to parse a string and test character by character like IMEime demonstrated.
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: If var is upper/lower with international characters

20 May 2016, 08:35

Masonjar13 already gave you a working answer.
Masonjar13 wrote:

Code: Select all

var:="ДОБРО"
stringUpper,upper,var
if(var==upper)
    msgbox Upper
just me
Posts: 9462
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: If var is upper/lower with international characters

20 May 2016, 09:03

'Modern' function:

Code: Select all

#NoEnv
Var := "ДОБРО"
MsgBox, 0, IsUpper(Var), % "IsUpper(""" . Var . """) = " . IsUpper(Var)

IsUpper(String) {
   Return (String == Format("{:U}", String))
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Joey5 and 257 guests