Skip to content
⌘ NSIS Forum Archive

Typecasting in NSIS?

4 posts

parasoul#

Typecasting in NSIS?

I want to do the C-equivalent of this:

char c = (char)74;
printf("%c",c); //J 
c++;
printf("%c",c); //K 

My best guess:

StrCpy $R2 "J"
IntOp $R2 $R2 + 1
MessageBox MB_OK $R2 
$R2 is treated as 0 in this example. Is there a way to have integers represented as their char-equivalent in NSIS?

I know how to do it with System plugin and using wsprintf but I'd prefer to not use that method
Anders#
StrCpy $0 74
IntFmt $1 "%c" $0
DetailPrint $1
IntOp $0 $0 + 1
IntFmt $1 "%c" $0
DetailPrint $1 
parasoul#
Originally Posted by Anders View Post
StrCpy $0 74
IntFmt $1 "%c" $0
DetailPrint $1
IntOp $0 $0 + 1
IntFmt $1 "%c" $0
DetailPrint $1 
Ah yes I forgot about IntFmt

Wonderful thank you
Anders#
I don't think IntFmt was ever designed to handle %c so you have to be a little careful with values above 127 (outside ASCII range). Ansi installers probably use the active codepage and Unicode installers probably can't handle values that are in the surrogate range.