PRB: CreateFile() Does Not Handle OEM Chars as Expected (129544)
The information in this article applies to:
- Microsoft Win32s 1.3c
- Microsoft Win32s 1.2
- Microsoft Win32s 1.25
- Microsoft Win32s 1.25a
- Microsoft Win32s 1.3
- Microsoft Win32s 1.30a
This article was previously published under Q129544 SYMPTOMS
When 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.
CAUSE
CreateFile() 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.
RESOLUTION
To 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().
STATUS
This behavior is by design and will not be changed in Win32s, because
it may break existing Win32-based applications.
MORE INFORMATION
The 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.
Modification Type: | Major | Last Reviewed: | 3/16/2004 |
---|
Keywords: | KB129544 |
---|
|