NSIS/Reference

[NSIS] StrLower

MoongStory 2024. 12. 9. 18:06
반응형
# 호출 예
# ${StrLower} '반환' '원본 문자열'
# ${StrLower} $0 $1
# ${StrLower} $0 $0
# ${StrLower} $0 "StRiNg"
!macro _StrLower un
	Function ${un}_StrLower
		Exch $R0	# Original
	string
		Push $R1	# Final
	string
		Push $R2	# Current
	character
		Push $R3
		Push $R4
		StrCpy $R1 ""
		Loop:
			StrCpy $R2 $R0 1	# Get next character
			StrCmp $R2 "" Done
			StrCpy $R0 $R0 "" 1
			StrCpy $R3 122		# 122 = ASCII code for z
		Loop2:
			IntFmt $R4 %c $R3	# Get character from current ASCII code
			StrCmp $R2 $R4 Match
			IntOp $R3 $R3 - 1
			StrCmp $R3 91 NoMatch Loop2	# 90 = ASCII code one beyond Z
		Match:
			StrCpy $R2 $R4		# It 'matches' (either case) so grab the lowercase version
		NoMatch:
			StrCpy $R1 $R1$R2	# Append to the final string
			Goto Loop
		Done:
		StrCpy $R0 $R1	# Return the
	final string
		Pop $R4
		Pop $R3
		Pop $R2
		Pop $R1
		Exch $R0
	FunctionEnd
!macroend
!insertmacro _StrLower ""
;!insertmacro _StrLower "un."
!macro StrLower OUTPUT str_origin
	Push "${str_origin}"
	!ifndef __UNINSTALL__
		Call _StrLower
	!else
		Call un._StrLower
	!endif
	Pop "${OUTPUT}"
!macroend
!define StrLower "!insertmacro StrLower"
반응형