Internationalization and localization tools


Character Manipulation Function

char* gcvt(double value, int digits, char* buffer);

char* _gcvt(double value, int digits, char* buffer);

Internationalization (I18n) Function Overview

The gcvt function converts the floating-point value to a null-terminated character string (which includes a decimal point and a possible sign byte) and stores the string in buffer. No overflow checking is performed, and the return is a pointer to buffer. digits is the number of significant digits stored.

_gcvt is the Windows-only version of gcvt.

I18n Issues

gcvt/_gcvt should not be used for strings that will be displayed to the user because the decimal separator and the position of the sign byte are not dependent on the numeric settings of the user's locale. In addition, these functions cannot be used with wide character strings.

Alternatively, one of the sprintf functions should be used, as these functions use the setting of the user locale's LC_NUMERIC category when formatting floating-point values. See String Formatting in C and C++ for a discussion on locale-sensitive formatting in internationalized applications.

And, as a final option on Windows platforms only: if the floating-point string does not need to be stored in a wide character string or formatted according to locale, consider using the more secure version _gcvt_s, if available.

Recommended Replacements*

*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