Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Translates a string into the OEM-defined character set.
Syntax
BOOL CharToOemA(
[in] LPCSTR pSrc,
[out] LPSTR pDst
);
Parameters
[in] pSrc
Type: LPCTSTR
The null-terminated string to be translated.
[out] pDst
Type: LPSTR
The destination buffer, which receives the translated string. If the CharToOem 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 CharToOem is being used as a wide-character function.
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
Security Considerations
Using this function incorrectly might compromise the security of your program. For example, miscalculating the proper size of the lpszDst buffer, especially when the application is used in both ANSI and Unicode versions, can cause a buffer overflow. For more information, see Security Considerations: International Features and Security Considerations: Windows User Interface.
Note
The winuser.h header defines CharToOem as an alias that 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 is 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
Conceptual
Reference