View source for Module:Check isxn
From HandWiki
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
-- This template is a copy of the ISXN validation code from [[Module:Citation/CS1]]
-- which allows for validating ISBN, ISMN, and ISSN without invoking a citation template
local p = {}
--[[--------------------------< IS _ V A L I D _ I S X N >-----------------------------------------------------
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
local function is_valid_isxn (isxn_str, len)
local temp = 0;
isxn_str = { isxn_str:byte(1, len) }; -- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
len = len+1; -- adjust to be a loop counter
for i, v in ipairs( isxn_str ) do -- loop through all of the bytes and calculate the checksum
if v == string.byte( "X" ) then -- if checkdigit is X (compares the byte value of 'X' which is 0x58)
temp = temp + 10*( len - i ); -- it represents 10 decimal
000
1:0
Templates used on this page:
- Template:Documentation subpage (view source)
- Template:Error-small (view source)
- Template:Module other (view source)
- Template:Module rating (view source)
- Template:Ombox (view source)
- Template:Small (view source)
- Template:Template link (view source)
- Template:Tl (view source)
- Module:Arguments (view source)
- Module:Check isxn (view source)
- Module:Check isxn/doc (view source)
- Module:Effective protection level (view source)
- Module:Error (view source)
- Module:Message box (view source)
- Module:Message box/configuration (view source)
- Module:No globals (view source)
- Module:Yesno (view source)
Return to Module:Check isxn.