Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

SetFileApisToANSI function (fileapi.h)

  • 2021-06-29
Feedback

In this article

Causes the file I/O functions to use the ANSI character set code page for the currentprocess. This function is useful for 8-bit console input and output operations.

Syntax

void SetFileApisToANSI();

Return value

None

Remarks

The file I/O functions whose code page is set bySetFileApisToANSI are thosefunctions exported by KERNEL32.DLL that accept or return a file name.SetFileApisToANSI sets the code page per process, rather than per thread or percomputer.

TheSetFileApisToANSI function complements theSetFileApisToOEM function, which causes the same setof 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 bydefault. This means that strings returned by the console functions may not be processed correctly by otherfunctions, and vice versa. For example, if theFindFirstFileA function returns a string that containscertain extended ANSI characters, and the 8-bit console functions are set to use the OEM code page, then theWriteConsoleA function does not display the stringproperly.

Use theAreFileApisANSI function to determinewhich code page the set of file I/O functions is currently using. Use theSetConsoleCP andSetConsoleOutputCP functions to set the code pagefor the 8-bit console functions.

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

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

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

TechnologySupported
Server Message Block (SMB) 3.0 protocolYes
SMB 3.0 Transparent Failover (TFO)Yes
SMB 3.0 with Scale-out File Shares (SO)Yes
Cluster Shared Volume File System (CsvFS)Yes
Resilient File System (ReFS)Yes

Requirements

RequirementValue
Minimum supported clientWindows XP [desktop apps only]
Minimum supported serverWindows Server 2003 [desktop apps only]
Target PlatformWindows
Headerfileapi.h (include Windows.h, WinBase.h)
LibraryKernel32.lib
DLLKernel32.dll

See also

AreFileApisANSI

File Management Functions

FindFirstFileA

SetConsoleCP

SetConsoleOutputCP

SetFileApisToOEM

WriteConsoleA


Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo