Skip to content

utilities to deal with ISBNs (International Standard Book Numbers)

Notifications You must be signed in to change notification settings

TJamesCorcoran/isbn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

ISBN utilities

by Travis J I Corcoran ( [email protected] )

Installation

In a rails project, add

gem "isbn"            , :git => "http://github.com/tjamescorcoran/isbn"

to you Gemfile, then from the command line

bundle

Intro

ISBNs (International Standard Book Numbers) define a namespace and a number standard for books.

ISBNs come in multiple varieties, which can cause problems. e.g.: you may have data that says that book X has ISBN Y, but when you scan the barcode on the back of book X, you get number Z. How do you compare a scanned number to a number you received from some third party?

This gem provides utilities to translate ISBNs.

First, an overview of ISBN varieties:

10 digits: ISBN10
	 * 9 data digits
	 * 1 check digit

12 digits: ISBN10 + 2-digit suplement
	  * 9 digits data
	  * ??

13 digits: ISBN13 / EAN13 (which is a superset of UPC-13...)
	  * 3 digits EAN prefix ("Bookland" = "978" or "979")
	  * 9 ISBN data digits
	  * 1 check digit (using a different algorithm from above!)

15 digits: ISBN10 + 5-digit price suplement
	  * 9 digits data
	  * 1 digit currency code (5 = USD, 0 = UKB)
	  * 4 digit price

18 digits:
	   * 13 digits: ISBN13
	   * 5 digits: EAN 5 (price info)

How to use this library

This library provides tools to convert any format to 13 digits. This allows for canonicalization before storage

book = Book[12]
book.isbn = Isbn.convert_to_13(Book[12].isbn)
book.save!

or before comparison

Isbn.convert_to_13("978123456789051299") == Isbn.convert_to_13("1234567890")

Note on lossiness

There are a few conversions that can be made back and forth without loss of data: bookland prefix (978 or 979) can be removed or prepended, checksums for a 10-digit ISBN can be stripped out and replaced w the different checksum for a 13 digit ISBN, etc.

Other conversions are inherently lossy: once price information is removed from a 12, 15, or 18 digit ISBN, that info is gone for good.

Bugs

  • Tests needed
  • This library is focused on converting to ISBN-13. We've got all the raw tools to support bidirectional conversions, but they're not fully supported.

References

Situation at HeavyInk.com

  • Diamond solicitations : ISBN10 (mostly)
  • Diamond website : ISBN13+5 (mostly)
  • Our scanner returns : ISBN13 / ISBN13+5 / 14chars
  • Google wants : 10 / 13
  • our canonical db representation : ISBN13

About

utilities to deal with ISBNs (International Standard Book Numbers)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages