Internationalization and localization tools


File and Path Function

FILE *fdopen(int filedes, const char *mode);

FILE *_fdopen(int handle, const char *mode);

FILE *_wfdopen(int handle, const wchar_t *mode);

FILE *_tfdopen(int handle, const TCHAR *mode);

Internationalization (I18n) Function Overview

The fdopen and _fdopen functions return a new stream for the file descriptor filedes (or handle on Windows platforms); else NULL in the event of an error.

The mode character string specifies the file access, and can be one of the following:

"r" to open the file for reading. If the file does not exist or cannot be found, the function call fails.
"w" to open an empty file for writing. If the given file exists, its contents are destroyed.
"a" to open the file for writing at the end of the file (appending); creates the file first if it doesn't exist.
"r+" to open the file for both reading and writing. (The file must exist.)
"w+" to open an empty file for both reading and writing. If the given file exists, its contents are destroyed.
"a+" to open the file for reading and appending; creates the file first if it doesn't exist.

Other characters may appear after these permissions characters to specify additional options for the call. However, always put the mode ("r", "w+", etc.) first; that is the only part you are guaranteed will be understood by all systems. See the MSDN Library for details on the various modes and their interactions on Windows systems; or the GNU C Library for flags supported by the GCC compiler.

On Windows platforms, _wfdopen is the wide-character version of _fdopen; its argument is a wide-character string. There is no ANSI wide-character equivalent.

_tfdopen is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either _fdopen or _wfdopen.

I18n Issues

Use the appropriate version of the function as required for internationalization support.

On ANSI UTF-16 platforms, if necessary, use a conversion function to convert the wide-character string to a multibyte-character string and then call fdopen.

See File I/O, which discusses reading and writing non-ASCII text data files.

Recommended Replacements*

*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.

File and Path Functions

 

Lingoport internationalization and localization services and software