Function toBanglaDigits

  • Converts a number or numeric string to Bangla digits. Non-digit characters and existing Bangla digits are retained as is.

    Parameters

    • num: string | number

      The number or string to convert.

    • strict: boolean = false

      If true, throws an error for invalid input.

    Returns string

    The converted string with Bangla digits.

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

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