Visualizza wikitesto di Modulo:Check isxn
Non si dispone dei permessi necessari per modificare questa pagina, per i seguenti motivi:
È possibile visualizzare e copiare il codice sorgente di questa pagina.
-- 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
-- Importato dalla versione del 30 marzo 2016 di :en:Module:Check isxn
-- https://en.wikipedia.org/w/index.php?title=Module:Check_isxn&oldid=712698918
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
Template utilizzato in questa pagina:
Torna a Modulo:Check isxn.