View source for Module:BaseConvert
Jump to navigation
Jump to search
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
local p = {}
local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
function normalizeFullWidthChars(s)
return mw.ustring.gsub(s, '[!-~]', function(s)
return mw.ustring.char(mw.ustring.codepoint(s, 1) - 0xFEE0)
end)
end
function _convert(n, base, from, precision, width, default, prefix, suffix)
n = '' .. n -- convert to a string
-- strip off any leading '0x' (unless x is a valid digit in the input base)
from = tonumber(from)
if not from or from < 34 then
local c
n, c = n:gsub('^(-?)0[Xx]', '%1')
if c > 0 and not from then from = 16 end
end
-- check for a negative sign. Do this while the input is still in string form,
000
1:0
Template used on this page:
Return to Module:BaseConvert.