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 digits 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. Most books published prior to 2019 have UCC 978, but over the years 979 has become more common, especially in books from newly-established small presses.

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 in reviews into ISBN-10s which can be used in Amazon links (Hello! It's been more than 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-12-200-0852-5 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-12-200-0852-5  9791220008525  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 option 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.
−d
Output will be in machine-readable “database” (CSV: Comma-Separated Value) format, one line per ISBN argument. See the “CSV Format Output” section below for details.
−g
Print the name of the ISBN registration group from the prefix.
−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.7.tar.gz: Gzipped TAR archive (49 Kb)

Included in the archive are the Perl program isbniser 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. The isbniser program is monolithic and requires no other files to run; it may be installed anywhere. It is created automatically from its component files under control of the Makefile.

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

CSV Format Output

When the −d option is specified, output from ISBNiser consists of one line per ISBN argument on the command line in Comma-Separated Value (CSV) format. The fields are as follows. Fields which may contain non-alphanumeric characters are always enclosed in double quotes.

  1. Status: numeric status
  2. ISBN-13, no delimiters
  3. ISBN-13, with delimiters (quoted)
  4. ISBN-10, no delimiters (“Unmappable” if 979- prefix)
  5. ISBN-10, with delimiters (“Unmappable” if 979- prefix) (quoted)
  6. Registration group name (quoted)
  7. Amazon associates URL (quoted)
  8. ISBN Registration group database date (quoted)


This product (software, documents, and data files) is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (legal text). You are free to copy and redistribute this material in any medium or format, and to remix, transform, and build upon the material for any purpose, including commercially. You must give credit, provide a link to the license, and indicate if changes were made. If you remix, transform, or build upon this material, you must distribute your contributions under the same license as the original.

This product is provided with no warranty, either expressed or implied, including but not limited to any implied warranties of merchantability or fitness for a particular purpose, regarding these materials and is made available available solely on an “as-is” basis.