Quantcast
Channel: AutoIt v3 - Developer Chat
Viewing all articles
Browse latest Browse all 750

proposed change to UDF '_StringTitleCase()'

$
0
0

currently it looks like this...

AutoIt         
; #FUNCTION# ==================================================================================================================== ; Author ........: BrewManNH ; Modified ......: ; =============================================================================================================================== Func _StringTitleCase($sString)     Local $fCapNext = True, $sChr = "", $sReturn = ""     For $i = 1 To StringLen($sString)         $sChr = StringMid($sString, $i, 1)         Select             Case $fCapNext = True                 If StringRegExp($sChr, "[a-zA-Z\xC0-\xFF0-9]") Then                     $sChr = StringUpper($sChr)                     $fCapNext = False                 EndIf             Case Not StringRegExp($sChr, "[a-zA-Z\xC0-\xFF'0-9]")                 $fCapNext = True             Case Else                 $sChr = StringLower($sChr)         EndSelect         $sReturn &= $sChr     Next     Return $sReturn EndFunc   ;==>_StringTitleCase

i am NO expert on RegEx, but there is a problem with the above line...

Case Not StringRegExp($sChr, "[a-zA-Z\xC0-\xFF'0-9]")

that will cause: 's (as in: that's) to become: 'S when the apostrophe is hex 2019:

suggested change is to simply add the missing char to the group, and possibly (*UCP)?:

Case Not StringRegExp($sChr, "(*UCP)[a-zA-Z\xC0-\xFF0-9'’]")

Viewing all articles
Browse latest Browse all 750

Latest Images

Trending Articles



Latest Images