Exported method WideCharToMultiByte to convert Windows wchar_t strings to multibyte

This commit is contained in:
Fabrizio Bertocci 2021-06-21 23:30:50 +02:00
parent ac3ac44d06
commit 70828ee0ca
3 changed files with 23 additions and 2 deletions

View file

@ -1,2 +1,12 @@
.include "o/libc/nt/codegen.inc" .include "o/libc/nt/codegen.inc"
.imp kernel32,__imp_WideCharToMultiByte,WideCharToMultiByte,0 .imp kernel32,__imp_WideCharToMultiByte,WideCharToMultiByte,1553
.text.windows
WideCharToMultiByte:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_WideCharToMultiByte(%rip),%rax
jmp __sysv2nt8
.endfn WideCharToMultiByte,globl
.previous

View file

@ -7093,7 +7093,7 @@ imp 'WerpNotifyLoadStringResource' WerpNotifyLoadStringResource KernelBase
imp 'WerpNotifyLoadStringResourceWorker' WerpNotifyLoadStringResourceWorker kernel32 1540 imp 'WerpNotifyLoadStringResourceWorker' WerpNotifyLoadStringResourceWorker kernel32 1540
imp 'WerpNotifyUseStringResource' WerpNotifyUseStringResource KernelBase 1809 imp 'WerpNotifyUseStringResource' WerpNotifyUseStringResource KernelBase 1809
imp 'WerpNotifyUseStringResourceWorker' WerpNotifyUseStringResourceWorker kernel32 1541 imp 'WerpNotifyUseStringResourceWorker' WerpNotifyUseStringResourceWorker kernel32 1541
imp 'WideCharToMultiByte' WideCharToMultiByte kernel32 0 # KernelBase imp 'WideCharToMultiByte' WideCharToMultiByte kernel32 1553 8
imp 'WidenPath' WidenPath gdi32 1941 imp 'WidenPath' WidenPath gdi32 1941
imp 'Win32DeleteFile' Win32DeleteFile shell32 164 imp 'Win32DeleteFile' Win32DeleteFile shell32 164
imp 'WinExec' WinExec kernel32 1543 imp 'WinExec' WinExec kernel32 1543

View file

@ -91,6 +91,17 @@ bool32 TrackPopupMenu(int64_t hMenu, uint32_t uFlags, int32_t x, int32_t y,
int32_t nReserved, int64_t hWnd, int32_t nReserved, int64_t hWnd,
const struct NtRect *prcRect); const struct NtRect *prcRect);
int WideCharToMultiByte(unsigned int CodePage,
uint32_t dwFlags,
uint16_t * lpWideCharStr,
int cchWideChar,
char * lpMultiByteStr,
int cbMultiByte,
uint16_t * lpDefaultChar,
int * lpUsedDefaultChar
);
COSMOPOLITAN_C_END_ COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NT_WINDOWS_H_ */ #endif /* COSMOPOLITAN_LIBC_NT_WINDOWS_H_ */