SetFileApisToANSI

Far Manager

SetFileApisToANSI

The SetFileApisToANSI function causes the file I/O functions to use the ANSI character set code page. This function is useful for 8-bit console input and output operations.
VOID SetFileApisToANSI(VOID);

Parameters

This function has no parameters.

Return value

This function has no return value.

Remarks

The SetFileApisToANSI function complements the SetFileApisToOEM function, which causes file I/O functions to use the OEM character set code page.

The 8-bit console functions use the OEM code page by default. 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 other functions, and vice versa. For example, if the FindFirstFileA function returns a string that contains certain extended ANSI characters, and the 8-bit console functions are set to use the OEM code page, then the WriteConsoleA function does not display the string properly.

Use the AreFileApisANSI function to determine which code page the set of file I/O functions is currently using. Use the SetConsoleCP and SetConsoleOutputCP functions to set the code page for the 8-bit console functions.

To solve the problem of code page incompatibility, it is best to use Unicode for console applications. Console applications that use Unicode are much more versatile than those that use 8-bit console functions. Barring that solution, a console application can call the SetFileApisToOEM to cause the set of file I/O functions to use OEM character set strings rather than ANSI character set strings. Use the SetFileApisToANSI to set those functions back to the ANSI code page.

The SetFileApisToANSI and SetFileApisToOEM functions affect the following set of Win32 file functions.

Function Description
_lopen open existing file
CopyFile copy file
CreateDirectory create directory
CreateFile create/open an object (file, pipe, etc.)
CreateProcess create process
DeleteFile delete file
FindFirstFile start searching for a file object
FindNextFile continue searching
GetCurrentDirectory get the current directory
GetDiskFreeSpace get disk info
GetDriveType get drive type
GetFileAttributes get file attributes
GetFullPathName get path to a file
GetModuleFileName get full name of the module
GetModuleHandle get handle of the module
GetSystemDirectory get path to the system directory
GetTempFileName get name for a temporary file
GetTempPath get path to the TEMP directory
GetVolumeInformation get file system information
GetWindowsDirectory get path to the Windows directory
LoadLibrary load library (DLL)
LoadLibraryEx load library (DLL)
MoveFile move/rename file or directory
MoveFileEx move/rename file or directory
OpenFile create/open/delete file
RemoveDirectory delete directory
SearchPath search for a file
SetCurrentDirectory set current directory
SetFileAttributes set file attributes

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

See also: