OemToCharBuffW function (winuser.h)

Translates a specified number of characters in a string from the OEM-defined character set into either an ANSI or a wide-character string.

Syntax

BOOL OemToCharBuffW(
  [in]  LPCSTR lpszSrc,
  [out] LPWSTR lpszDst,
  [in]  DWORD  cchDstLength
);

Parameters

[in] lpszSrc

Type: LPCSTR

One or more characters from the OEM-defined character set.

[out] lpszDst

Type: LPTSTR

The destination buffer, which receives the translated string. If the OemToCharBuff function is being used as an ANSI function, the string can be translated in place by setting the lpszDst parameter to the same address as the lpszSrc parameter. This cannot be done if the OemToCharBuff function is being used as a wide-character function.

[in] cchDstLength

Type: DWORD

The number of characters to be translated in the buffer identified by the lpszSrc parameter.

Return value

Type: BOOL

The return value is always nonzero except when you pass the same address to lpszSrc and lpszDst in the wide-character version of the function. In this case the function returns zero and GetLastError returns ERROR_INVALID_ADDRESS.

Remarks

Unlike the OemToChar function, the OemToCharBuff function does not stop converting characters when it encounters a null character in the buffer pointed to by lpszSrc. The OemToCharBuff function converts all cchDstLength characters.

Note

The winuser.h header defines OemToCharBuff as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-chartranslation-l1-1-0 (introduced in Windows 8)

See also

CharToOem

CharToOemBuff

Conceptual

OemToChar

Reference

Strings