Module isbn

ISBN utilities for Erlang including ISBN-10 and ISBN-13 check digit generators and validators.

Copyright © 2007 Matt Croydon

Version: 0.1.5

Authors: Matt Croydon (matt@ooiio.com) [web site: http://postneo.com].

Description

ISBN utilities for Erlang including ISBN-10 and ISBN-13 check digit generators and validators. Also included is a ISBN-10 to ISBN-13 conversion, and ISBN-13 to ISBN-10 when applicable.

A full test suite accompanies this module in the file isbn_test.erl

Function Index

check_digit_10/1Given a 9 digit list, calculates the ISBN-10 check digit and returns it.
check_digit_10_string/1Given an ISBN string containing 9 characters and optionally "-" characters, generate a list, chomping "-" characters, and then pass the results to check_digit_10/1.
check_digit_13/1Given a 12 digit list, calculates the ISBN-13 check digit and returns it.
check_digit_13_string/1Given 12 out of 13 characters of an ISBN as a string, chomp "-" characters and pass the result on to check_digit_13/1.
convert_10_to_13/1Given an ISBN-10, converts it to ISBN-13, checks validity, and returns the ISBN-13 or throws an error.
convert_10_to_13_string/1Given an ISBN-10 in string form, convert to a list, removing any "-" characters, and then pass it on to convert_10_to_13/1, converting it back to a string when it is done.
convert_13_to_10/1Given an ISBN-13, returns the correct ISBN-10 by dropping the first three digits and check digit then recalculating the new ISBN-10 check digit.
convert_13_to_10_string/1Given an ISBN-13 in string form, convert it to a list and sent it to convert_13_to_10/1, converting it back to a string when it's done.
validate_10/1Given a 10 digit ISBN, generates check digit and checks to see that is matches the last integer passed in.
validate_10_string/1Given an ISBN string containing 10 characters and optionally "-" characters, generate a list, chomping "-" characters, and then pass the results to validate_10/1.
validate_13/1Given a 13 digit ISBN as a list of integers, generates the check digit and returns true if it matches the check digit passed in, false otherwise.
validate_13_string/1Given an ISBN in string form, 13 characters total with optional "-" seperators, chomp "-" characters, convert them to a list and pass them on to validate_13/1.

Function Details

check_digit_10/1

check_digit_10(Isbn::List) -> integer()

throws atom()

Given a 9 digit list, calculates the ISBN-10 check digit and returns it.

check_digit_10_string/1

check_digit_10_string(Isbn::string()) -> integer() | string()

Given an ISBN string containing 9 characters and optionally "-" characters, generate a list, chomping "-" characters, and then pass the results to check_digit_10/1.

check_digit_13/1

check_digit_13(Isbn::List) -> integer()

throws atom()

Given a 12 digit list, calculates the ISBN-13 check digit and returns it.

check_digit_13_string/1

check_digit_13_string(Isbn::string()) -> integer()

Given 12 out of 13 characters of an ISBN as a string, chomp "-" characters and pass the result on to check_digit_13/1.

convert_10_to_13/1

convert_10_to_13(Isbn::List) -> List

throws atom()

Given an ISBN-10, converts it to ISBN-13, checks validity, and returns the ISBN-13 or throws an error.

convert_10_to_13_string/1

convert_10_to_13_string(Isbn::string()) -> string()

throws atom()

Given an ISBN-10 in string form, convert to a list, removing any "-" characters, and then pass it on to convert_10_to_13/1, converting it back to a string when it is done.

convert_13_to_10/1

convert_13_to_10(Isbn::List) -> List

throws atom()

Given an ISBN-13, returns the correct ISBN-10 by dropping the first three digits and check digit then recalculating the new ISBN-10 check digit.

If the given ISBN-13 does not begin with [9,7,8], an error is thrown because only 978- ISBN-13's can be translated in to ISBN-10.

convert_13_to_10_string/1

convert_13_to_10_string(Isbn::string()) -> string()

throws atom()

Given an ISBN-13 in string form, convert it to a list and sent it to convert_13_to_10/1, converting it back to a string when it's done.

validate_10/1

validate_10(Isbn::List) -> bool()

throws atom()

Given a 10 digit ISBN, generates check digit and checks to see that is matches the last integer passed in. Returns true or false, depending on if they match or not.

validate_10_string/1

validate_10_string(Isbn::string()) -> bool()

throws atom()

Given an ISBN string containing 10 characters and optionally "-" characters, generate a list, chomping "-" characters, and then pass the results to validate_10/1.

validate_13/1

validate_13(Isbn::List) -> bool()

throws atom()

Given a 13 digit ISBN as a list of integers, generates the check digit and returns true if it matches the check digit passed in, false otherwise.

validate_13_string/1

validate_13_string(Isbn::string()) -> bool()

throws atom()

Given an ISBN in string form, 13 characters total with optional "-" seperators, chomp "-" characters, convert them to a list and pass them on to validate_13/1.


Generated by EDoc, May 8 2007, 21:28:28.