WideCharToMultiByte function Null safety kernel32

int WideCharToMultiByte(
  1. int CodePage,
  2. int dwFlags,
  3. Pointer<Utf16> lpWideCharStr,
  4. int cchWideChar,
  5. Pointer<Utf8> lpMultiByteStr,
  6. int cbMultiByte,
  7. Pointer<Utf8> lpDefaultChar,
  8. Pointer<Int32> lpUsedDefaultChar
)

Maps a UTF-16 (wide character) string to a new character string. The new character string is not necessarily from a multibyte character set.

int WideCharToMultiByte(
  UINT   CodePage,
  DWORD  dwFlags,
  LPCWCH lpWideCharStr,
  int    cchWideChar,
  LPSTR  lpMultiByteStr,
  int    cbMultiByte,
  LPCCH  lpDefaultChar,
  LPBOOL lpUsedDefaultChar
);

Implementation

int WideCharToMultiByte(
    int CodePage,
    int dwFlags,
    Pointer<Utf16> lpWideCharStr,
    int cchWideChar,
    Pointer<Utf8> lpMultiByteStr,
    int cbMultiByte,
    Pointer<Utf8> lpDefaultChar,
    Pointer<Int32> lpUsedDefaultChar) {
  final _WideCharToMultiByte = _kernel32.lookupFunction<
      Int32 Function(
          Uint32 CodePage,
          Uint32 dwFlags,
          Pointer<Utf16> lpWideCharStr,
          Int32 cchWideChar,
          Pointer<Utf8> lpMultiByteStr,
          Int32 cbMultiByte,
          Pointer<Utf8> lpDefaultChar,
          Pointer<Int32> lpUsedDefaultChar),
      int Function(
          int CodePage,
          int dwFlags,
          Pointer<Utf16> lpWideCharStr,
          int cchWideChar,
          Pointer<Utf8> lpMultiByteStr,
          int cbMultiByte,
          Pointer<Utf8> lpDefaultChar,
          Pointer<Int32> lpUsedDefaultChar)>('WideCharToMultiByte');
  return _WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar,
      lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar);
}