Crate thai_number_text

Crate thai_number_text 

Source
Expand description

Thai Number Text - Convert numbers to Thai textual representations.

A minimal, no_std-compatible crate for converting numbers to Thai text.

§Capabilities

  • Integer and float conversion to Thai text
  • Thai Baht currency formatting
  • String input for arbitrarily large numbers (beyond i64)
  • Scientific notation support
  • Three เอ็ด modes: Colloquial, RoyalInstitute, Military

§Feature Flags

  • std: Enables standard library support (for benchmarks/tests)
  • serde: Enables Serialize/Deserialize for types

§Examples

use thai_number_text::{to_text_i64, to_text_str, to_text_scientific, to_baht, ThaiTextOptions};

let opts = ThaiTextOptions::new();

// Integer conversion
assert_eq!(to_text_i64(21, &opts), "ยี่สิบเอ็ด");

// Currency
assert_eq!(to_baht(100.50, &opts), "หนึ่งร้อยบาทห้าสิบสตางค์");

// String input (supports arbitrarily large numbers)
assert_eq!(to_text_str("1e6", &opts).unwrap(), "หนึ่งล้าน");

// Scientific notation: 9.22 × 10^37
assert_eq!(
    to_text_scientific(9.22, 37, &opts),
    "เก้าจุดสองสอง คูณ สิบยกกำลังสามสิบเจ็ด"
);

Structs§

ThaiTextOptions
Configuration options for Thai number text conversion.

Enums§

EtMode
Mode for using เอ็ด (et) for the digit 1 in unit position.
ParseError
Error type for string parsing failures.
ThaiNumber
A number that can be converted to Thai text.

Functions§

to_baht
Converts an amount to Thai Baht currency text.
to_text
Converts a number to Thai text (generic wrapper).
to_text_f64
Converts an f64 to Thai text.
to_text_i64
Converts an i64 to Thai text.
to_text_scientific
Converts a number in scientific notation to Thai text.
to_text_str
Converts a numeric string to Thai text.