ISBNiser

by John Walker


International Standard Book Numbers (ISBNs) are unique numbers which identify published books. Each edition of a book (for example, hardcover, paperback, and electronic) has its own ISBN, so a bookstore can order the book based on the ISBN and be assured of receiving the desired edition. ISBNs are integral to the operation of on-line book vendors and distributors of electronic editions of books.

The ISBN standard was adopted in 1970 by the International Organisation for Standardisation (ISO) as ISO 2108. Initially, ISBNs were 10 character codes, with the first digit indicating the so-called “registration group”, which generally identifies the language of the publication. In 2007, ISBNs were extended to a 13-digit code compatible with the European Article Number (EAN) system of product identification, with a Unique Country Code (UCC) of 978 denoting “Bookland”, with 979 reserved for expansion of that address space as necessary. With the change to 13-digit codes, the original ISBNs were redesignated ISBN-10, and the new ones ISBN-13. Any ISBN-10 can be converted to an ISBN-13 with a UCC of 978, and any ISBN-13 in UCC 978 can be converted to an ISBN-10. ISBNs with a UCC of 979 cannot, however, be converted back to ISBN-10. As of this writing (late 2017), almost all ISBN-13s have a UCC of 978: I can't recall ever encountering one in 979, and I read a lot of books.

The ISBN-10 and ISBN-13 systems are very different. Both incorporate a check digit to guard against errors in manual transcription or machine scanning, but they use different algorithms. In ISBN-10, the check digit can range from 0 to 10, with the last character of the code using the letter “X” to denote a check digit with value 10. ISBN-13 uses the EAN checksum algorithm, which yields check digits from 0 through 9, and hence are all numeric. Both ISBN-10 and ISBN-13 can include non-alphanumeric delimiters, which often separate the prefix (for ISBN-13), registration group element, registrant, publication, and checksum, for example “978-0-471-64877-2”. These delimiters are of no significance in interpreting the number: a specification of “978.0.471.64877.2” or “9780471648772” is completely equivalent. Traditionally, the larger publishers always delimited their registrant number to show how big they were (a two or three digit number is prestigious), but increasingly now, you see ISBN-13s with no delimiters: just thirteen digits. (And, since you didn't ask, Fourmilab's ISBN-13 block is “978-1-936047-xx-c”—six digits of registrant!) The structure of ISBNs permits parsing its fields purely from the number without delimiters.

As one who reads and reviews a lot of books, I find myself frequently working with ISBNs. My site is an Amazon.com associate, and to pay the rent, I often need to turn ISBN-13s I cite into reviews into ISBN-10s which can be used in Amazon links (Hello! It's been ten years, Amazon. Gonna fix that one of these days?). Enter ISBNiser.

ISBNiser is a command line utility which can be run on any system which supports the Perl language. It accepts arguments which can be either ISBN-13s or ISBN-10s, with or without delimiters, checks them for validity, and displays the ISBN in all valid forms including, if configured, an Amazon associate link ready to go ka-ching into your reading budget every time a visitor to your site clicks it.

ISBNiser is run from the command line. Here is a sample query:

$ isbniser.pl -cmyassocacct \
        0-309-09657-X 0.309.09657.X 1844135438 \
        9780385611015 978-0-471-64877-2 978.0.471.64877.2 \
        979-0-471-64877-1 1844135437
ISBN-10:        0-309-09657-X     030909657X  ISBN-13:  9780309096577     978-0-309-09657-7
http://www.amazon.com/dp/030909657X/?tag=myassocacct
ISBN-10:        0.309.09657.X     030909657X  ISBN-13:  9780309096577     978.0.309.09657.7
http://www.amazon.com/dp/030909657X/?tag=myassocacct
ISBN-10:        1-84413-543-8     1844135438  ISBN-13:  9781844135431     978-1-84413-543-1
http://www.amazon.com/dp/1844135438/?tag=myassocacct
ISBN-13:    978-0-385-61101-5  9780385611015  ISBN-10:     0385611013         0-385-61101-3
http://www.amazon.com/dp/0385611013/?tag=myassocacct
ISBN-13:    978-0-471-64877-2  9780471648772  ISBN-10:     0471648779         0-471-64877-9
http://www.amazon.com/dp/0471648779/?tag=myassocacct
ISBN-13:    978.0.471.64877.2  9780471648772  ISBN-10:     0471648779         0.471.64877.9
http://www.amazon.com/dp/0471648779/?tag=myassocacct
ISBN-13:    979-0-471-64877-1  9790471648771  ISBN-10:     Unmappable
Invalid ISBN: 1844135437

As in this example, you can specify multiple ISBNs in any of the accepted formats on the command line. If an ISBN-13 has a prefix of “979”, it cannot be represented as an ISBN-10 and will be shown as “Unmappable”. Invalid ISBNs (those which have an invalid check digit, are too long or short, or contain invalid characters) will be reported.

By default, non-alphanumeric delimiters in the ISBNs specified are discarded and the same delimiter re-inserted in the ISBN-10 and ISBN-13 displayed at the positions determined by parsing the number. If the ISBN is invalid or in a format not defined by the standard, it will be displayed without delimiters. The −p preserves the original delimiters in the specified ISBN.

You can control the operation of ISBNiser by specifying the following options on the command line.

−aURL
The specified URL will be used in Amazon associate links. Specify the Amazon site to which you wish the link directed, such as www.amazon.com, www.amazon.co.uk, www.amazon.co.jp, etc. The default Amazon URL is set by the $Amazon variable in the program.
−caccount
Amazon associate links will credit account for purchases made through them. The default is set by the $credit variable in the program. If the null string is specified, no associate account will be credited.
−n
Do not verify subsequent specifications on the command line. This allows generating Amazon associate links for ASINs which do not verify as ISBNs.
−p
Preserve the original delimiters in the specified ISBN. Otherwise, delimiters are re-generated automatically by parsing the number.
−r
Use the alternative Amazon associate account configured as $creditR within the program. You can credit to any account you wish with the −c option; this is simply a convenience when you frequently credit to a main and alternative account.
−u   −−help
Print how-to-call information. This information is also printed if the program is called with no arguments.
−v
Verify subsequent specifications on the command line. This reverses the effect of a previous −n option.

Downloading and Installation

ISBNiser may be downloaded from the following link:

isbniser-1.3.tar.gz: Gzipped TAR archive (8.8 Kb)

Included in the archive are the Perl program isbniser.pl as well as this document. You can run the Perl program from directory into which you extracted it or install it in a system library directory to make it accessible to all users. You'll usually want to rename the program from “isbniser.pl” to “isbniser” when installing it.

This program requires no Perl modules; it will work on a base installation of Perl.


This software is in the public domain. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided “as is” without express or implied warranty.

Fourmilab Home Page