Skip to content
⌘ NSIS Forum Archive

Convert string of ASCII values to general string

2 posts

DGiff52#

Convert string of ASCII values to general string

I have been working on an issue for quite a while trying to figure out if this can be done natively in NSIS or if I will need to use something externally to solve my problem. What I need to do is convert a string of three-digit ASCII codes into a general string. For instance, I will need to convert "084069083084" into "TEST".

T=084
E=069
S=083
T=084

Any ideas if this is something that can be done in NSIS using base functions? I have been looking all over to no avail. Any hints would be extremely appreciated. Thanks!
Animaether#edited
IntFmt outputVariable "%c" inputASCIIvalue 
( for information on the IntFmt 'format' string, see: http://msdn.microsoft.com/en-us/library/ms647550 . Apparently this is omitted in the documentation )

OutFile "test.exe"
Section
SectionEnd
var input
var output
var counter
var subdigits
var firstdigit
var char
Function .onInit
    StrCpy $input "084069083084"
    StrCpy $counter 0
    StrCpy $output ""
    StrCpy $subdigits $input 3 $counter
    _loop:
        StrCpy $firstdigit $subdigits 1
        StrCmp $firstdigit "0" 0 +2
            StrCpy $subdigits $subdigits 2 1
        IntFmt $char "%c" $subdigits
        StrCpy $output "$output$char"
        IntOp $counter $counter + 3
        StrCpy $subdigits $input 3 $counter
    StrCmp $subdigits "" 0 _loop
    MessageBox MB_OK "[$output]"
    Abort
FunctionEnd