মডিউল:bn-digit
অবয়ব
এই মডিউলের জন্য মডিউল:bn-digit/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
local p = {}
-- ০‑৯ map (ASCII → Bengali Unicode)
local digitMap = {
['0'] = '০', ['1'] = '১', ['2'] = '২', ['3'] = '৩', ['4'] = '৪',
['5'] = '৫', ['6'] = '৬', ['7'] = '৭', ['8'] = '৮', ['9'] = '৯'
}
----------------------------------------------------------------------
-- Core function (safe for other modules to call directly)
----------------------------------------------------------------------
function p.toBn(str)
-- Ensure we’re working with a string
if type(str) ~= 'string' then
str = tostring(str or '')
end
-- gsub walks the string; %d matches any ASCII digit
return (str:gsub('%d', digitMap))
end
----------------------------------------------------------------------
-- #invoke entry point: {{#invoke:BnDigits|convert|12345}}
----------------------------------------------------------------------
function p.convert(frame)
local s = frame.args[1] or frame:getParent().args[1] or ''
return p.toBn(s)
end
return p