Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Nikowiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Identificadores
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} --[[ ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn(). 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. ]] -- Funci贸n tra铆da de en:Module:Citation/CS1 function p.esValidoISXN (isxn_str, len) local temp = 0; isxn_str = { isxn_str:byte(1, len) }; -- make a table of bytes 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 temp = temp + 10*( len - i ); -- it represents 10 decimal else temp = temp + tonumber( string.char(v) )*(len-i); end end return temp % 11 == 0; -- returns true if calculation result is zero end -- Adaptaci贸n de la funci贸n checkisbn de en:Module:Citation/CS1 function p.esValidoISBN(isbn) -- El isbn solo contiene n煤meros, guiones, espacios en blanco y el d铆gito de -- control X. if not isbn or isbn:match("[^%s-0-9X]") then return false end -- Eliminar los guiones y espacios en blanco isbn = isbn:gsub( "-", "" ):gsub( " ", "" ) local longitud = isbn:len() if longitud == 10 then -- La X solo puede ir al final. if not isbn:match( "^%d*X?$" ) then return false end return p.esValidoISXN(isbn, 10); elseif longitud == 13 then -- isbn13 local temp = 0; -- Debe comenzar por 978 o 979 if not isbn:match( "^97[89]%d*$" ) then return false end -- Comprobar el d铆gito de control isbn = { isbn:byte(1, longitud) }; for i, v in ipairs( isbn ) do temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) ); end return temp % 10 == 0; else return false end end -- Funci贸n que devuelve un enlace al ISBN si es correcto y si no (por ejemplo si -- ya est谩 enlazado) lo devuelve sin m谩s. -- Por defecto no se incluye el literal ISBN delante. function p.enlazarISBN(isbn, opciones) if p.esValidoISBN(isbn) then return '[[Especial:FuentesDeLibros/' .. isbn .. '|' .. isbn .. ']]' else return isbn end end function p.enlazarOCLC(oclc, opciones) if tonumber(oclc) then return '[http://www.worldcat.org/oclc/' .. oclc .. ' ' .. oclc .. ']' else return oclc end end return p
Summary:
Please note that all contributions to Nikowiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Nikowiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Identificadores/doc
(
edit
)
Search
Search
Editing
Module:Identificadores
Add topic