function canonical_ISBN in ISBN Field 6
1 call to canonical_ISBN()
- canonical_ISN in ./
isbn.inc
File
- ./
isbn.inc, line 350
Code
function canonical_ISBN($isbn_proto) {
$isbn_proto = ISN_clean($isbn_proto);
global $country_group_map;
$cg = country_group_code($isbn_proto);
$cglen = strlen($cg);
$pubandbook = substr($isbn_proto, $cglen, 9 - $cglen);
$checkdigit = $isbn_proto[9];
if (is_array($country_group_map[$cg])) {
$publen = prefix_length_from_map($pubandbook, $country_group_map[$cg][0]);
if ($cglen + $publen == 9) {
return "{$cg}-{$pubandbook}-{$checkdigit}";
}
else {
$pubcode = substr($pubandbook, 0, $publen);
$bookno = substr($pubandbook, $publen);
return "{$cg}-{$pubcode}-{$bookno}-{$checkdigit}";
}
}
else {
return "{$cg}-{$pubandbook}-{$checkdigit}";
}
}