[DLL/SO/DYLIB] Unicode to Ascii via Structure
Posted: Sat Nov 19, 2016 10:38 am
What is the best way to get a string inside a structure out of a Unicode DLL? If the caller is ASCII caller will always read the string in ASCII which leads to erroneous strings.
For example i try to return "Hello World" from a DLL, the returned string is read and displayed in the ASCII caller as only "H".
Compile with PB 5.31 please.
For example i try to return "Hello World" from a DLL, the returned string is read and displayed in the ASCII caller as only "H".
Code: Select all
; DLL UNICODE
structure myInfo
str$
endStructure
procedureDLL getInfo ()
*inf. myInfo = allocateStructure (myInfo)
*inf \ str$ = "Hello World"
procedureReturn *inf
endProcedure
; ExecutableFormat = Shared dll
; EnableUnicode
Code: Select all
; CALLER ASCII
structure myInfo
str$
endStructure
lb = openLibrary (#pb_Any, "unicode.dll")
*inf.myInfo = callFunction (lb, "getInfo")
debug *inf \ str$