Old 20th July 2014, 14:01   #1
eugene25
Junior Member
 
Join Date: Jul 2014
Posts: 3
How to convert string to UCS-2LE

The problem is to convert string into Unicode form UCS-2LE, here the sample.
input: 12345
output UCS2-LE string of bytes: 31003200330034003500
Any idea how to solve it?
eugene25 is offline   Reply With Quote
Old 20th July 2014, 14:27   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 893
First of all, NSIS Unicode 2.46.5 is a fork of the official package, so we can't provide any support for it.

Try the latest NSIS 3.x release, as the NSIS 3.x releases support both ansi and unicode. To compile a unicode installer, use 'Unicode True'. Put the string into the script and the compiler should convert it for you.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 20th July 2014, 14:43   #3
eugene25
Junior Member
 
Join Date: Jul 2014
Posts: 3
Hello I assume the question do not correlate with NSIS version
eugene25 is offline   Reply With Quote
Old 20th July 2014, 15:13   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Quote:
!define EMPTY ""
StrCpy $0 "12345"
StrCpy $1 0
StrCpy $2 ""
loop:
StrCpy $3 $0 1 $1
StrCmp "" $3 done
System::Call 'kernel32::lstrcpyW(*i.r4,wr3)'
IntFmt $4 %x $4
StrLen $3 $4
IntCmp $3 4 +3
StrCpy $4 $4${EMPTY}0
Goto -3
StrCpy $2 $2$4
IntOp $1 $1 + 1
Goto loop
done:
DetailPrint $2
If you need to deal with things outside the ASCII range in a specific codepage you should call MultiByteToWideChar...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
unicode

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump