Page 1 of 1
create unicode executable can't read api return string .
Posted: Thu Aug 17, 2006 3:49 pm
by PureBoy
Structure MODULEENTRY32tmp
dwSize.l
th32ModuleID.l
th32ProcessID.l
GlblcntUsage.l
ProccntUsage.l
modBaseAddr.l
modBaseSize.l
hModule.l
szModule.s{256}
szExePath.s{260}
EndStructure
var
md.MODULEENTRY32tmp
the md\szExePath is null
if not unicode executable,md\szExePath will return a file path.
how to get string in the unicode mode.
help me!
which function can convert ansi to unicode or convert unicode to ansi.
Re: create unicode executable can't read api return string .
Posted: Sun Aug 20, 2006 10:18 pm
by sverson
PureBoy wrote:
which function can convert ansi to unicode or convert unicode to ansi.
Code: Select all
Structure MODULEENTRY32tmp
dwSize.l
th32ModuleID.l
th32ProcessID.l
GlblcntUsage.l
ProccntUsage.l
modBaseAddr.l
modBaseSize.l
hModule.l
szModule.s{256}
szExePath.s{260}
EndStructure
md.MODULEENTRY32tmp
md\szExePath="C:\TESTPATH\ASCII"
Debug md\szExePath
Debug @md\szExePath
PokeS(@md\szExePath,"C:\TESTPATH\UNICODE",-1,#PB_Unicode)
Debug md\szExePath ; just 1st char
Debug PeekS(@md\szExePath,-1,#PB_Unicode)
You may also take a look at these (API)
Unicode and Character Set Functions:
GetTextCharset: Retrieves a character set identifier For the font that is currently selected into a specified device context.
GetTextCharsetInfo: Retrieves information about the character set of the font that is currently selected into a specified device context.
IsDBCSLeadByte: Determines whether a character is a lead byte.
IsDBCSLeadByteEx: Determines whether a character is a lead byte.
IsTextUnicode: Determines whether a Buffer is likely To contain a form of Unicode text.
MultiByteToWideChar: Maps a character string To a wide-character (Unicode) string.
TranslateCharsetInfo: Translates based on the specified character set, code page, Or font Signature Value.
WideCharToMultiByte: Maps a wide-character string To a new character string.
Posted: Sun Aug 20, 2006 11:05 pm
by sverson
...some examples...
Code: Select all
Procedure.l Ansi2Unicode(Ansi.s)
;/ Ansi [in] Character string to be converted.
;/ pointer [out] Points to a buffer that receives the translated (UNICODE) string.
Protected AnsiLen.l, UniLen.l
AnsiLen = Len(Ansi)
UniLen = MultiByteToWideChar_(#CP_ACP, 0, Ansi, AnsiLen, 0, 0)
If UniLen
*Unicode = SysAllocStringLen_(0, UniLen)
If MultiByteToWideChar_(#CP_ACP, 0, Ansi, AnsiLen, *Unicode, UniLen)
ProcedureReturn *Unicode
EndIf
EndIf
ProcedureReturn 0
EndProcedure
Procedure.s Unicode2Ansi(*Unicode,UniLen.l)
;/ *Unicode [in] Points To the wide-character string To be converted.
;/ UniLen [in] Specifies the number of wide characters in the string pointed to by the lpWideCharStr parameter. If this value is -1, the string is assumed to be null-terminated and the length is calculated automatically. The length will include the null-terminator.
;/ string [out] The translated (ANSI) string.
Protected Ansi.s,AnsiLen.l
AnsiLen = WideCharToMultiByte_(#CP_ACP,0,*Unicode,UniLen,0,AnsiLen,0,0)
If AnsiLen
Ansi = Space(AnsiLen)
If WideCharToMultiByte_(#CP_ACP,0,*Unicode,UniLen,@Ansi,AnsiLen,0,0);"•",#True)
ProcedureReturn Ansi
EndIf
EndIf
ProcedureReturn ""
EndProcedure
Test1.s = "TestText ANSI-UNICODE"
*Test2 = Ansi2Unicode(Test1)
Debug Unicode2Ansi(*Test2,-1)
CallDebugger
Posted: Mon Aug 21, 2006 8:48 pm
by blueznl
Posted: Mon Aug 21, 2006 8:59 pm
by sverson
blueznl wrote:unicode <> widechar !
Oh yes - you're right!
BTW - the Survival Guide is a great thing.
Posted: Thu Sep 28, 2006 3:10 am
by PureBoy
good!