Next: , Previous: , Up: Internationalization   [Contents][Index]


6.25.4 Number Input and Output

The following procedures allow programs to read and write numbers written according to a particular locale. As an example, in English, “ten thousand and a half” is usually written 10,000.5 while in French it is written 10 000,5. These procedures allow such differences to be taken into account.

Scheme Procedure: locale-string->integer str [base [locale]]
C Function: scm_locale_string_to_integer (str, base, locale)

Convert string str into an integer according to either locale (a locale object as returned by make-locale) or the current process locale. If base is specified, then it determines the base of the integer being read (e.g., 16 for an hexadecimal number, 10 for a decimal number); by default, decimal numbers are read. Return two values (see Multiple Values): an integer (on success) or #f, and the number of characters read from str (0 on failure).

This function is based on the C library’s strtol function (see strtol in The GNU C Library Reference Manual).

Scheme Procedure: locale-string->inexact str [locale]
C Function: scm_locale_string_to_inexact (str, locale)

Convert string str into an inexact number according to either locale (a locale object as returned by make-locale) or the current process locale. Return two values (see Multiple Values): an inexact number (on success) or #f, and the number of characters read from str (0 on failure).

This function is based on the C library’s strtod function (see strtod in The GNU C Library Reference Manual).

Scheme Procedure: number->locale-string number [fraction-digits [locale]]

Convert number (an inexact) into a string according to the cultural conventions of either locale (a locale object) or the current locale. By default, print as many fractional digits as necessary, up to an upper bound. Optionally, fraction-digits may be bound to an integer specifying the number of fractional digits to be displayed.

Scheme Procedure: monetary-amount->locale-string amount intl? [locale]

Convert amount (an inexact denoting a monetary amount) into a string according to the cultural conventions of either locale (a locale object) or the current locale. If intl? is true, then the international monetary format for the given locale is used (see international and locale monetary formats in The GNU C Library Reference Manual).


Next: , Previous: , Up: Internationalization   [Contents][Index]