Skip to content

Commit

Permalink
use low-level FFI call for WideCharToMultiByte
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-krivanek committed Mar 31, 2020
1 parent 2799b91 commit 696c547
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/System-Platforms/WinPlatform.class.st
Expand Up @@ -148,13 +148,32 @@ WinPlatform >> virtualKey: virtualKeyCode [

{ #category : #'string-manipulation' }
WinPlatform >> wideCharacterToMultiByteCodepage: codepage flags: flags input: input inputLen: inputLen output: output outputLen: outputLen [
^self ffiCall: #(int WideCharToMultiByte(uint codepage,
ulong flags,
Win32WideString input,
int inputLen,
String output,
int outputLen,
0,
0
))

"To be independent on UnifiedFFI package, we must use low-level FFI call. The following code is based on this FFI call:
^self ffiCall: #(int WideCharToMultiByte(uint codepage, ulong flags, Win32WideString input, int inputLen, String output, int outputLen, 0, 0 ))"

^(ExternalLibraryFunction
name: 'WideCharToMultiByte'
module: 'Kernel32'
callType: 0
returnType: ExternalType signedLong
argumentTypes:
{ExternalType unsignedLong.
ExternalType unsignedLong.
ExternalType void asPointerType.
ExternalType signedLong.
ExternalType char asPointerType.
ExternalType signedLong.
ExternalType unsignedLong.
ExternalType unsignedLong.})
invokeWithArguments:
{codepage.
flags.
input getHandle.
inputLen.
output.
outputLen.
0.
0}
]

0 comments on commit 696c547

Please sign in to comment.