Internationalization and localization tools


Character Manipulation Function

char* ecvt(double value, int ndigit, int *decpt, int *neg);

char* _ecvt(double value, int ndigit, int *decpt, int *neg);

Internationalization (I18n) Function Overview

The function ecvt converts the floating-point number value to a string with at most ndigit decimal digits. The returned string contains no decimal point or sign. The first digit of the string is non-zero (unless value is actually zero) and the last digit is rounded. *decpt is set to the index in the string of the first digit after the decimal point. *neg is set to a nonzero value if value is negative, zero otherwise.

_ecvt is the Windows-only version of ecvt.

I18n Issues

ecvt/_ecvt 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.

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