Function toEnglishDigits

  • Converts Bangla digits to English digits. Non-digit characters and existing English digits are retained as is.

    Parameters

    • num: string | number

      The string or number to convert.

    • strict: boolean = false

      If true, throws an error for invalid input.

    Returns string

    The converted string with English digits.

    If the input is null, undefined, or exceeds the maximum safe integer value.

    toEnglishDigits("১২৩"); // "123"
    toEnglishDigits("১২৩.৪৫"); // "123.45"
    toEnglishDigits("123.45"); // "123.45" (no change)
    toEnglishDigits("abc"); // "abc" (non-numeric characters are retained)