lc_parse_number (public)

 lc_parse_number num locale [ integer_only_p ]

Defined in packages/acs-lang/tcl/localization-procs.tcl

Converts a number to its canonical representation by stripping everything but the decimal separator and trimming left 0's so it won't be octal. It can process the following types of numbers:

  • Just digits (allows leading zeros).
  • Digits with a valid thousands separator, used consistently (leading zeros not allowed)
  • Either of the above with a decimal separator plus optional digits after the decimal marker
The valid separators are taken from the given locale. Does not handle localized signed numbers in this version. The sign may only be placed before the number (with/without whitespace). Also allows the empty string, returning same.

Parameters:
num (required)
Localized number
locale (required)
Locale
integer_only_p (optional, defaults to "0")
True if only integers returned
Returns:
Canonical form of the number
Error:
If unsupported locale or not a number

Testcases:
lang_test__lc_procs
[ show source ]
Show another procedure: