StrUpper: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
mNo edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|sunjammer}}
|<small>Author: [[{{ns:2}}:sunjammer|sunjammer]] ([[{{ns:3}}:sunjammer|talk]], [[{{ns:-1}}:Contributions/sunjammer|contrib]])</small>
|}
<br style="clear:both;">
== The Script Incredible Survival ==
Salvaged 2 times (!):
*from the ultra old Sunjammer's NSIS Archive;
*and from the old NSIS Archive.


== Description ==
== Description ==
Line 50: Line 43:


== Credits ==
== Credits ==
Kichik reckons that the original was provided by Dave Laundon aka [[user:Eccles | Eccles].
Kichik reckons that the original was provided by Dave Laundon aka [[User:Eccles|Eccles]].
 
[[Category:String Functions]]

Latest revision as of 12:05, 12 December 2005

Author: sunjammer (talk, contrib)


Description

This function converts a string to upper case. This doesn't work with latin accents and Unicode.

The Function

; StrUpper
;   Converts the string on the stack to uppercase (in an ASCII sense)
; Usage:
;   Push <string>
;   Call StrUpper
;   Pop <STRING>
Function StrUpper
  Exch $0 ; Original string
  Push $1 ; Final string
  Push $2 ; Current character
  Push $3
  Push $4
  StrCpy $1 ""
Loop:
  StrCpy $2 $0 1 ; Get next character
  StrCmp $2 "" Done
  StrCpy $0 $0 "" 1
  StrCpy $3 65 ; 65 = ASCII code for A
Loop2:
  IntFmt $4 %c $3 ; Get character from current ASCII code
  StrCmp $2 $4 Match
  IntOp $3 $3 + 1
  StrCmp $3 91 NoMatch Loop2 ; 91 = ASCII code one beyond Z
Match:
  StrCpy $2 $4 ; It 'matches' (either case) so grab the uppercase version
NoMatch:
  StrCpy $1 $1$2 ; Append to the final string
  Goto Loop
Done:
  StrCpy $0 $1 ; Return the final string
  Pop $4
  Pop $3
  Pop $2
  Pop $1
  Exch $0
FunctionEnd

Credits

Kichik reckons that the original was provided by Dave Laundon aka Eccles.