Internationalization and localization tools


Character Manipulation Function

char* gets(char* buffer);

wchar_t* _getws(wchar_t* buffer);

TCHAR* _getts(TCHAR* buffer);.

Internationalization (I18n) Function Overview

The gets function reads a line from standard input (stdin), and stores the null-terminated string in buffer. It returns null in the event of an error, or else a pointer to buffer.

_getws is only supported on Windows platforms and is the wide-character version of gets; its argument and return are wide-character string buffers.

_getts is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either gets or _getws.

I18n Issues

Use the appropriate version of the function as required for internationalization support, noting the following:

Because there is no way to limit the number of characters read by gets and _getws, they should not be used. Instead, on Windows, use a more secure string function, and on ANSI UTF-8 platforms, use getline. Otherwise, on all platforms, consider using a version of the function fgets, which avoids buffer overruns by passing in a maximum number of characters to read.

See Character I/O for a discussion on non-ASCII character input/output in an internationalized application.

Recommended Replacements*

As mentioned above, on Windows platforms, a more secure string function should be used; whereas, on ANSI platforms, use getline rather than gets. Otherwise, use the appropriate variation of the safer fgets function. These are shown in preferred order in the following table:

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

Character Manipulation Functions

 

Lingoport internationalization and localization services and software