|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: May 2007
Posts: 2
|
converting bytes into string, string into int, then back.
Hello All:
I may have missed this issue in old posts or the FAQ, but bear with me. I'm attempting to emulate the following Java behavior in an NSIS installer: byte[] password = new byte[4]; ... String str = new String(password, 0, 4); int i = Integer.parseInt(str); i += 16432; String image = String.valueOf(i); int b = image.compareTo(inputString); The crux is the conversion of four sequential bytes (representing ASCII character codes) into the equivalent string, parsing this string value into an int, and then converting the int back into its string image. Has anyone seen anything similar to this? Cheers. Brad |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
http://nsis.sourceforge.net/Asc
and IntFmt $0 "%c" 65 should get you started, or should Integer.parseInt() give you a int from 4 bytes (4 char's)? IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#3 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
or is this an actual string that is always formated like a number, eg "136532"? In NSIS there are no int's, everything is stored as a string, for things like IntCmp and IntOp, the string is converted to a number, operation takes place and result is stored as a string in the output variable
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: May 2007
Posts: 2
|
The parseInt() method call is like the atoi() function in C.
The four bytes are interpreted as a string, which is itself interpreted as the image of an integer value. |
|
|
|
|
|
#5 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
so
StrCpy $0 "1234" IntOp $1 $0 + 16432 StrCmp $1 "input" match nomatch is not what you want? IntOp $PostCount $PostCount + 1 |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|