void AnsiToOem(hpszWindows, hpszOem) | |||||
const char _huge* hpszWindows; | /* address of string to translate | */ | |||
char _huge* hpszOem; | /* address of buffer for string | */ |
The AnsiToOem function translates a string from the Windows character set into the specified OEM character set.
hpszWindows
Points to a null-terminated string of characters from the Windows character set.
hpszOem
Points to the location where the translated string is to be copied. To translate the string in place, this parameter can be the same as hpszWindows.
This function does not return a value.
The string to be translated can be greater than 64K in length.
Windows-to-OEM mappings are defined by the keyboard driver, where this function is implemented. Some keyboard drivers may have different mappings than others, depending on the machine environment, and some keyboard driver support loading different OEM character sets; for example, the standard U.S. keyboard driver for an IBM keyboard supports loadable code pages, with the default being code page 437 and the most common alternative being code page 850. (The Windows character set is sometimes referred to as code page 1007.)
The OEM character set must always be used when accessing string data created by MS-DOS or MS-DOS applications. For example, a word processor should convert OEM characters to Windows characters when importing documents from an MS-DOS word processor. When an application makes an MS-DOS call, including a C run-time function call, filenames must be in the OEM character set, whereas they must be presented to the user in Windows characters (because the Windows fonts use Windows characters).
The following example is part of a dialog box in which a user would create a directory by typing a name in an edit control:
case IDOK:
GetWindowText(GetDlgItem(hwndDlg, ID_EDITDIRNAME), szDirName,
sizeof(szDirName));
AnsiToOem(szDirName, szDirName);
mkdir(szDirName);
EndDialog(hwndDlg, 1);
return TRUE;