numeric_to_words library
Thai number-to-words utilities public API.
Re-exports common utilities organized by domain:
- Core number formatting (thaiIntToWords, thaiNumberToWords)
- Currency formatting (thaiBahtText)
- Options for customization (ThaiNumberOptions, ThaiBahtTextOptions)
- Decimals and fractions (thaiDecimal, thaiFraction)
- Digit-by-digit reading (thaiDigits)
- Thai numerals parsing (thaiNumeralsToArabic, arabicDigitsToThai, parseThaiInteger)
- Roman numerals parsing and reading (parseRoman, romanToThaiWords)
Classes
- CurrencyRegistry
- Registry of currency units (selected set per provided list). Note: Names align with the Royal Institute list where applicable.
- CurrencyUnit
- Domain entity and value objects for currency names in English and Thai.
- ThaiBahtTextOptions
- Options controlling Baht text formatting.
- ThaiDecimalOptions
- Options controlling Decimal number reading.
- ThaiDigitsOptions
- Options for reading digits one-by-one (e.g., 123 -> "หนึ่งสองสาม").
- ThaiNumberOptions
- Options controlling general number formatting in Thai.
Functions
-
arabicDigitsToThai(
String input) → String -
Convert any Arabic digits in
inputto Thai numerals. Other chars unchanged. -
englishCurrencyText(
num amount, CurrencyUnit currency) → String - Format a number into English currency words, with minor unit when needed.
-
parseRoman(
String roman) → BigInt - Parse a Roman numeral string to integer (BigInt).
-
parseThaiInteger(
String input) → BigInt - Parse an integer string consisting of Thai numerals (optional leading sign).
-
romanToThaiWords(
String roman, {ThaiNumberOptions options = const ThaiNumberOptions()}) → String - Converts a Roman numeral string directly to Thai words. Example: 'IV' -> 'สี่', 'XV' -> 'สิบห้า'.
-
thaiBahtText(
num amount, {ThaiBahtTextOptions options = const ThaiBahtTextOptions()}) → String - Converts a numeric amount to Thai Baht text ("Thai Baht Text").
-
thaiCurrencyText(
num amount, CurrencyUnit currency) → String - Format a number into Thai currency words using existing Thai number-to-words.
-
thaiDecimal(
num value, {ThaiDecimalOptions options = const ThaiDecimalOptions()}) → String - Reads a decimal number in Thai, pronouncing the decimal point and each digit after it. Examples:
-
thaiDigits(
String numeric, {ThaiDigitsOptions options = const ThaiDigitsOptions()}) → String - Reads a number as individual Thai digits without composing into place-value words. Example: 12345 -> "หนึ่งสองสามสี่ห้า". Supports negative and optional decimal point word.
-
thaiFraction(
BigInt numerator, BigInt denominator, {ThaiNumberOptions options = const ThaiNumberOptions()}) → String - Reads a fraction in Thai using the pattern "X ส่วน Y". Examples:
-
thaiIntToWords(
int value, {ThaiNumberOptions options = const ThaiNumberOptions()}) → String -
thaiNumberToWords(
BigInt value, {ThaiNumberOptions options = const ThaiNumberOptions()}) → String - Options container (assumed existing in options.dart): class ThaiNumberOptions { final String zeroWord; // default 'ศูนย์' final String negativeWord; // default 'ลบ' const ThaiNumberOptions({this.zeroWord = 'ศูนย์', this.negativeWord = 'ลบ'}); }
-
thaiNumeralsToArabic(
String input) → String -
Convert any Thai numerals in
inputto Arabic digits. Other chars unchanged.