PRB: CreateFile() Does Not Handle OEM Chars as ExpectedLast reviewed: January 15, 1997Article ID: Q129544 |
The information in this article applies to:
SYMPTOMSWhen CreateFile() is passed a filename string that contains an OEM character, the name of the file created is not as expected. In particular, a file created with CreateFile() cannot be opened with OpenFile() when OpenFile() is passed the same filename string. For example, suppose that the ANSI filename string contains a lower-case e accent character (0x0e9). The file created by CreateFile() contains an upper-case E and the file created by OpenFile() contains an upper-case E accent character.
CAUSECreateFile() is implemented with calls to MS-DOS. MS-DOS converts the given file names to upper-case letters. OpenFile() is implemented with a thunk to the 16-bit Windows OpenFile(). OpenFile() converts the file name to upper-case before calling MS-DOS. The conversion that the 16-bit OpenFile() is doing is different from the conversion performed by MS-DOS for the OEM characters. The result is that different filenames are created for the same string passed to CreateFile() and OpenFile() if the name contains OEM characters.
RESOLUTIONTo make the file name created by CreateFile() consistent with the file name created by OpenFile(), call AnsiUpper() on the file name string before calling CreateFile().
STATUSThis behavior is by design and will not be changed in Win32s, because it may break existing Win32-based applications.
MORE INFORMATIONThe 16-bit OpenFile() will fail to find an existing file if the file contains OEM characters but not an explicit full path. This also occurs with the 32-bit OpenFile(), because it is thunked to the 16-bit OpenFile(). SearchFile() will also fail to find files if the file name contains OEM characters or if the search path (lpszpath != NULL) contains OEM characters. NOTE: In 16-bit Windows and Win32s 1.2 and earlier, OpenFile() returns the filename in OEM characters. However, the Win32 API documentation states that OpenFile() should return an ANSI string. Starting with the next version of Win32s, OpenFile() will return an ANSI string, as it does under Windows NT.
|
KBCategory: kbprg kbprb
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |