convert to UPPER/lowercase

Helpful script writing tricks and HowTo's
partof
Posts: 20
Joined: 16 Jan 2016, 08:38

convert to UPPER/lowercase

10 Oct 2017, 04:30

I did not find a way to make it work with UTF-8 (any idea?) but here is a working code for Asc characters

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Credit: taken here https://autohotkey.com/board/topic/24431-convert-text-uppercase-lowercase-capitalized-or-inverted/ and slightly modified)
Last edited by partof on 10 Oct 2017, 05:22, edited 2 times in total.
User avatar
jNizM
Posts: 2290
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: convert to UPPER/lowercase

10 Oct 2017, 04:34

[AHK] 1.1.26.01 x64 Unicode | [WIN] 10 Pro (Version 1703) x64
My GitHub Profile | Donations are appreciated if I could help you
User avatar
Exaskryz
Posts: 2608
Joined: 17 Oct 2015, 20:28

Re: convert to UPPER/lowercase

11 Oct 2017, 00:31

For a crude way on shifting to all uppercase, all lowercase, or inverting, you could make an extensive array? Here's sample code for just Upper and Lowercasing; not sure how you'd best approach an Invert. Probably compare if the original character is the lowercase or uppercase with If (Inv_char=characters[Inv_Char]["upper"]) or ["lower"] then assign to the converted string the opposite.

No idea if Format as jNizM links to would work on characters outside the standard 26 (52) character English alphabet.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Edit: This doesn't work if you use string:="ÉÍ", because there is no É or Í in the first array; anyone have a better idea regarding the array management? I kind of feel like this would be appropriate, but it's kind of backwards and would eat a lot of time.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
Xtra
Posts: 878
Joined: 02 Oct 2015, 12:15

Re: convert to UPPER/lowercase

11 Oct 2017, 02:18

Exaskryz wrote:No idea if Format as jNizM links to would work on characters outside the standard 26 (52) character English alphabet.


Code: [Select all] [Download] GeSHi © Codebox Plus

chars := "éÉé"
String := Format("{:U}", chars)
MsgBox,,Upper, % chars . " converted to: " . string

chars := "ÉéÉ"
String := Format("{:L}", chars)
MsgBox,,Lower, % chars . " converted to: " . string
ExitApp
User avatar
jeeswg
Posts: 2650
Joined: 19 Dec 2016, 01:58
Location: UK

Re: convert to UPPER/lowercase

11 Oct 2017, 07:43

I'm not sure exactly what you're looking for. This example shows how you can take text stored as what I call 'UTF-8 bytes', convert it to UTF-16, make it uppercase, and convert it back to 'UTF-8 bytes'.

The aim of the script is to start with vText2 and end up with vText4, but I start off with vText, to make it clear what vText2 contains.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
Exaskryz
Posts: 2608
Joined: 17 Oct 2015, 20:28

Re: convert to UPPER/lowercase

11 Oct 2017, 09:19

Xtra wrote:
Exaskryz wrote:No idea if Format as jNizM links to would work on characters outside the standard 26 (52) character English alphabet.


Code: [Select all] [Download] GeSHi © Codebox Plus

chars := "éÉé"
String := Format("{:U}", chars)
MsgBox,,Upper, % chars . " converted to: " . string

chars := "ÉéÉ"
String := Format("{:L}", chars)
MsgBox,,Lower, % chars . " converted to: " . string
ExitApp


Well sweet, it even works on Greek letters: chars:=ΔδΔ. If anyone knows other alphabets, would be cool to see how those are handled.
ozzii
Posts: 290
Joined: 30 Oct 2013, 06:04

Re: convert to UPPER/lowercase

12 Oct 2017, 02:25

The Serbian Cyrillic and Latin is also converted.

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 5 guests