NlsDllCodePageTranslation function (gb18030.h)

Used to get code page information or do conversion, depending on flag settings.

Note  Do not use this function. It can behave differently in different versions of Windows. To convert GB18030 bytes to Unicode characters or Unicode characters to GB18030 bytes, use the MultiByteToWideChar and WideCharToMultiByte functions.
 

Syntax

DWORD NlsDllCodePageTranslation(
  [in]      DWORD    CodePage,
  [in]      DWORD    dwFlags,
  [in, out] LPSTR    lpMultiByteStr,
  [in]      int      cchMultiByte,
  [in, out] LPWSTR   lpWideCharStr,
  [in]      int      cchWideChar,
  [in]      LPCPINFO lpCPInfo
);

Parameters

[in] CodePage

The value of the code page. The code page value should be 54936. Otherwise, the function returns an error code.

[in] dwFlags

Flags specifying the translation. Possible values are defined in the following table.

Value Meaning
NLS_CP_CPINFO
Retrieve code page information in the buffer pointed to by lpCPInfo. The lpMultiByteStr, cchMultiByte, lpWideCharStr, and cchWideChar parameters are not used.
NLS_CP_MBTOWC
Convert GB18030 bytes to Unicode characters. The source GB18030 characters should be pointed to by lpMultiByteStr, and cchMultiByte should contain the byte count of the buffer. The Unicode result is stored in the buffer pointed to by lpWideCharStr, and cchWideChar should contain the character count of the Unicode buffer. If lpWideCharStr or cchWideChar is 0, the expected character count of the Unicode result is returned, and no conversion is done. The lpCPInfo parameter is not used in this case.
NLS_CP_WCTOMB
Convert Unicode characters to GB18030 bytes. The source Unicode string should be pointed to by lpWideCharStr, and cchWideChar should contain the character count of the buffer. The GB18030 result is stored in the buffer pointed to by lpMultiByteStr, and cchMultiByte should contain the byte count of the GB18030 buffer. If lpMultiByteStr or cchMultiByte is 0, the byte count of the GB18030 result is returned, and no conversion is done. The lpCPInfo parameter is not used in this case.

[in, out] lpMultiByteStr

Pointer to a buffer that contains multibyte GB18030 characters. This can be a source buffer or target buffer, depending on the value of dwFlags.

[in] cchMultiByte

Byte count of the multibyte buffer.

[in, out] lpWideCharStr

Pointer to a buffer that contains Unicode characters. This can be a source buffer or target buffer, depending on the value of dwFlags.

[in] cchWideChar

Character count of the Unicode buffer.

[in] lpCPInfo

Pointer to a CPINFO structure.

Return value

Returns 1 if successful. If the function does not succeed, it returns 0. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header gb18030.h
DLL C_g18030.dll

See also

MultiByteToWideChar

WideCharToMultiByte