 this template isu800 au800 copy ofu800 theu800 isxn validation code from module citation cs1u800 which allows foru800 validating isbn ismn andu800 issn without invoking au800 citation template local pu800 isbn 10u800 andu800 issn validator code calculates checksum across allu800 isbn issn digits including theu800 check digit. isbn 13u800 isu800 checked inu800 check_isbn . ifu800 theu800 number isu800 valid theu800 result will beu800 0u800. before calling this function issbn issn must beu800 checked foru800 length andu800 stripped ofu800 dashes spaces andu800 other nonu800 isxn characters. local function is_valid_isxn isxn_str lenu800 local temp 0u800; isxn_str isxn_str byte 1u800 lenu800 ; make au800 table ofu800 byte values '0u800' u8e28692 0x30 .. '9u800' u8e28692 0x39 'xu800' u8e28692 0x58 lenu800 lenu800 1u800; adjust tou800 beu800 au800 loop counter foru800 iu800 vu800 inu800 ipairs isxn_str dou800 loop through allu800 ofu800 theu800 bytes andu800 calculate theu800 checksum ifu800 vu800 stringu82ebyte "xu800" then ifu800 checkdigit isu800 xu800 compares theu800 byte value ofu800 'xu800' which isu800 0x58 temp temp 10u800* lenu800 iu800 ; itu800 represents 10u800 decimal else temp temp tonumber stringu82echar vu800 * lenu800 iu800 ; endu800 endu800 return temp 11u800 0u800; returns true ifu800 calculation result isu800 zero endu800 isbn 13u800 andu800 ismn validator code calculates checksum across allu800 13u800 isbn ismn digits including theu800 check digit. ifu800 theu800 number isu800 valid theu800 result will beu800 0u800. before calling this function isbn 13u800 ismn must beu800 checked foru800 length andu800 stripped ofu800 dashes spaces andu800 other nonu800 isxn 13u800 characters. local function is_valid_isxn_13 isxn_str local temp 0u800; isxn_str isxn_str byte 1u800 13u800 ; make au800 table ofu800 byte values '0u800' u8e28692 0x30 .. '9u800' u8e28692 0x39 foru800 iu800 vu800 inu800 ipairs isxn_str dou800 temp temp 3u800 2u800* iu800 2u800 * tonumber stringu82echar vu800 ; multiply oddu800 index digits byu800 1u800 even index digits byu800 3u800 andu800 sumu800; includes check digit endu800 return temp 10u800 0u800; sumu800 modulo 10u800 isu800 zero when isbn 13u800 ismn isu800 correct endu800 determines whether anu800 isbn string isu800 valid local function check_isbn isbn_str error_string ifu800 nilu800 isbn_str match " su800 0u800 9xu800 " then fail ifu800 isbn_str contains anything butu800 digits hyphens oru800 theu800 uppercase xu800 return error_string; endu800 isbn_str isbn_str gsub " " "" gsub " " "" ; remove hyphens andu800 spaces local lenu800 isbn_str lenu800 ; ifu800 lenu800 10u800 andu800 lenu800 13u800 then return error_string; endu800 ifu800 lenu800 10u800 then ifu800 isbn_str match " du800*xu800 " nilu800 then return error_string; endu800 return is_valid_isxn isbn_str 10u800 andu800   oru800 error_string; else local temp 0u800; ifu800 isbn_str match " 97u800 89u800 du800* " nilu800 then isbn13 begins with 978u800 oru800 979u800; ismn begins with 979u800 return error_string; endu800 return is_valid_isxn_13 isbn_str andu800   oru800 error_string; endu800 endu800 determines whether anu800 ismn string isu800 valid. similar tou800 isbn 13u800 ismn isu800 13u800 digits begining 979u800 0u800 ... andu800 uses theu800 same check digit calculations. seeu800 section 2u800 pages 9u8e2809312. local function check_ismn idu800 error_string local text; local valid_ismn true; idu800 idu800 gsub " su800 u8e28093 " "" ; strip spaces hyphens andu800 endashes from theu800 ismn ifu800 13u800 idu800 lenu800 oru800 idu800 match " 9790 du800* " nilu800 then ismn must beu800 13u800 digits andu800 begin 9790 valid_ismn false; else valid_ismn is_valid_isxn_13 idu800 ; validate ismn endu800 return valid_ismn andu800   oru800 error_string endu800 validate andu800 format anu800 issn. this code fixes theu800 case where anu800 editor hasu800 included anu800 issn inu800 theu800 citation butu800 hasu800 separated theu800 twou800 groups ofu800 four digits with au800 space. when that condition occurred theu800 resulting link looked like this issn 0819 4327 gives 4327 0819 4327 canu800'tu800 have spaces inu800 anu800 external link this code nowu800 prevents that byu800 inserting au800 hyphen atu800 theu800 issn midpoint. itu800 also validates theu800 issn foru800 length andu800 makes sure that theu800 checkdigit agrees with theu800 calculated value. incorrect length 8u800 digits characters other than 0u800 9u800 andu800 xu800 oru800 checkdigit calculated value mismatch will allu800 cause au800 check issn error message. local function check_issn idu800 error_string local issn_copy idu800; save au800 copy ofu800 unadulterated issn; useu800 this version foru800 display ifu800 issn does notu800 validate local text; local valid_issn true; ifu800 notu800 idu800 match ' du800 du800 du800 du800 du800 du800 du800 dxu800 ' then return error_string; endu800 idu800 idu800 gsub " su800 u8e28093 " "" ; strip spaces hyphens andu800 endashes from theu800 issn ifu800 8u800 idu800 lenu800 oru800 nilu800 idu800 match " du800*xu800 " then validate theu800 issn 8u800 digits long containing only 0u800 9u800 oru800 xu800 inu800 theu800 last position valid_issn false; wrong length oru800 improper character else valid_issn is_valid_isxn idu800 8u800 ; validate issn endu800 return valid_issn andu800   oru800 error_string endu800 function pu800u82echeck_isbn frame return check_isbn frameu82eargs 1u800 oru800 frame getparent .args 1u800 frameu82eargs 'error' oru800 frame getparent .args 'error' oru800 'error' endu800 function pu800u82echeck_ismn frame return check_ismn frameu82eargs 1u800 oru800 frame getparent .args 1u800 frameu82eargs 'error' oru800 frame getparent .args 'error' oru800 'error' endu800 function pu800u82echeck_issn frame return check_issn frameu82eargs 1u800 oru800 frame getparent .args 1u800 frameu82eargs 'error' oru800 frame getparent .args 'error' oru800 'error' endu800 return pu800 