Console Application Issues

The 8-bit console functions use the OEM code page. All other functions use the ANSI code page by default. This means that strings returned by the console functions may not be processed correctly by the other functions and vice versa. For example, if FindFirstFileA returns a string that contains certain extended ANSI characters, WriteConsoleA will not display the string properly.

The best long-term solution for a console application is to use Unicode. Barring that solution, a console application should use the SetFileApisToOEM function. That function changes relevant Win32 file functions so that they produce OEM character set strings rather than ANSI character set strings.

Following are the Win32 file functions:

_lopen
GetDriveType
LoadLibrary
CopyFile
GetFileAttributes
LoadLibraryEx
CreateDirectory
GetFullPathName
MoveFile
CreateFile
GetModuleFileName
MoveFileEx
CreateProcess
GetModuleHandle
OpenFile
DeleteFile
GetSystemDirectory
RemoveDirectory
FindFirstFile
GetTempFileName
SearchPath
FindNextFile
GetTempPath
SetCurrentDirectory
GetCurrentDirectory
GetVolumeInformation
SetFileAttributes
GetDiskFreeSpace
GetWindowsDirectory

When dealing with command lines, a console application should obtain the command line in Unicode form and convert it to OEM form, using the relevant character-to-OEM functions. Note, also, that argv uses the ANSI character set.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database