<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: PHP port of ISBN-10/13 tool</title>
	<atom:link href="http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/</link>
	<description>A library-geek blog</description>
	<pubDate>Tue, 02 Dec 2008 01:14:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Keith Nunn</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-291763</link>
		<dc:creator>Keith Nunn</dc:creator>
		<pubDate>Thu, 21 Feb 2008 15:01:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-291763</guid>
		<description>I have quite a complete ISBN test tool that does all of the above and also does GTIN-14.  It's for php5, but could likely be backported to php4 fairly easily.

If anyone is interested you'll find it at http://www.phpclasses.org/browse/package/1707.html

It's just called ISBNcheck (not a clever name, but it works)

kapn</description>
		<content:encoded><![CDATA[<p>I have quite a complete ISBN test tool that does all of the above and also does GTIN-14.  It&#8217;s for php5, but could likely be backported to php4 fairly easily.</p>
<p>If anyone is interested you&#8217;ll find it at <a href="http://www.phpclasses.org/browse/package/1707.html" rel="nofollow">http://www.phpclasses.org/browse/package/1707.html</a></p>
<p>It&#8217;s just called ISBNcheck (not a clever name, but it works)</p>
<p>kapn</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-119657</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Fri, 04 May 2007 22:26:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-119657</guid>
		<description>Here is a txt version

http://tinyurl.com/28ncrk</description>
		<content:encoded><![CDATA[<p>Here is a txt version</p>
<p><a href="http://tinyurl.com/28ncrk" rel="nofollow">http://tinyurl.com/28ncrk</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-109848</link>
		<dc:creator>Nicholas</dc:creator>
		<pubDate>Mon, 16 Apr 2007 21:26:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-109848</guid>
		<description>Am I crazy or is none of the code on this page complete?

Lines like this: for($i = 1; $i genchksum10($isbn2);

and blocks of code that end like this:

function isbn_genchksum13($isbn) {
        $isbn = trim($isbn);
        for ($i = 0; $i

Surely can't be correct. What is going on here? Is everyone just not good at copy and pasteing? Am I the idiot? I'm baffled.</description>
		<content:encoded><![CDATA[<p>Am I crazy or is none of the code on this page complete?</p>
<p>Lines like this: for($i = 1; $i genchksum10($isbn2);</p>
<p>and blocks of code that end like this:</p>
<p>function isbn_genchksum13($isbn) {<br />
        $isbn = trim($isbn);<br />
        for ($i = 0; $i</p>
<p>Surely can&#8217;t be correct. What is going on here? Is everyone just not good at copy and pasteing? Am I the idiot? I&#8217;m baffled.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-100907</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Tue, 27 Mar 2007 21:44:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-100907</guid>
		<description>Thijs, thanks for the pointer.  I'm in the US, dealing with American books.  It never occurred to me that there would be a standard for hyphenating or that international books would be hyphenated differently.

I poked around the site and didn't see  a guide for the 13 digit numbers.  I assume its the same as 10, except with the dash added after the opening 978.

I will update my function when I have some free time, and I'll post the code here.</description>
		<content:encoded><![CDATA[<p>Thijs, thanks for the pointer.  I&#8217;m in the US, dealing with American books.  It never occurred to me that there would be a standard for hyphenating or that international books would be hyphenated differently.</p>
<p>I poked around the site and didn&#8217;t see  a guide for the 13 digit numbers.  I assume its the same as 10, except with the dash added after the opening 978.</p>
<p>I will update my function when I have some free time, and I&#8217;ll post the code here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thijs</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-94353</link>
		<dc:creator>Thijs</dc:creator>
		<pubDate>Sun, 18 Mar 2007 17:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-94353</guid>
		<description>Hi Adam, your function &lt;code&gt;isbn_dashes();&lt;/code&gt; does not place the hyphens on the right place most of the times. It may be correct with some US-ISBN numbers, I doubt you've read the official guidelines:

&lt;a href="http://www.isbn.org/standards/home/isbn/international/hyphenation-instructions.asp" title="Hyphenation Instructions" rel="nofollow"&gt;Hyphenation Instructions&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hi Adam, your function <code>isbn_dashes();</code> does not place the hyphens on the right place most of the times. It may be correct with some US-ISBN numbers, I doubt you&#8217;ve read the official guidelines:</p>
<p><a href="http://www.isbn.org/standards/home/isbn/international/hyphenation-instructions.asp" title="Hyphenation Instructions" rel="nofollow">Hyphenation Instructions</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-73589</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Thu, 22 Feb 2007 19:34:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-73589</guid>
		<description>This is the collection of ISBN code I'm actively using, compiled from the original code and the comments.

I added the isnb_dashes($isbn) function, which accepts a 10 or 13 digit ISBN number and adds the dashes. This does not check the validity of the string, it just returns it.  If it isn't 10 or 13 characters long, the function returns false.

&lt;code&gt;
function isbn_convert($isbn) {
        $isbn2 = substr("978" . trim($isbn), 0, -1);
        $sum13 = isbn_genchksum13($isbn2);
        $isbn13 = "$isbn2-$sum13";
        return ($isbn13);
    }
 
function isbn_gettype($isbn) {
        $isbn = trim($isbn);
        if (preg_match('%[0-9]{12}?[0-9Xx]%s', $isbn)) {
            if (isbn_validatettn($isbn)==1){
                    return 13;
                       } else {return(-1);}
 
                } else if (preg_match('%[0-9]{9}?[0-9Xx]%s', $isbn)) {
              if (isbn_validateten($isbn)==1){
                    return 10;
                       } else {return -1;}
        } else {
            return -1;
        }
    }
 
function isbn_validateten($isbn) {
        $isbn = trim($isbn);
        $chksum = substr($isbn, -1, 1);
        $isbn = substr($isbn, 0, -1);
        if (preg_match('/X/i', $chksum)) { $chksum="10"; }
        $sum = isbn_genchksum10($isbn);
        if ($chksum == $sum){
            return 1;
        }else{
            return 0;
        }
    }
 
function isbn_validatettn($isbn) {
        $isbn = trim($isbn);
        $chksum = substr($isbn, -1, 1);
        $isbn = substr($isbn, 0, -1);
        if (preg_match('/X/i', $chksum)) { $chksum="10"; }
        $sum = isbn_genchksum13($isbn);
        if ($chksum == $sum){
            return 1;
        }else{
            return 0;
        }
    }
 
function isbn_genchksum13($isbn) {
        $t = 2;
        $isbn = trim($isbn);
                $b=0;
                for($i = 1; $i genchksum10($isbn2);
        if ($sum10==10) {$sum10='X';}
        $isbn10 = $isbn2.$sum10;
        return ($isbn10);
    }
		
## ISBN Add Dashes
function isbn_dashes($isbn) {
        switch(strlen($isbn)):
				    case 13:
						    return
								    substr($isbn,0,3)."-"
								    .substr($isbn,3,1)."-"
								    .substr($isbn,4,3)."-"
								    .substr($isbn,7,5)."-"
								    .substr($isbn,12,1);
								break;
				    case 10:
						    return
								    substr($isbn,0,1)."-"
								    .substr($isbn,1,3)."-"
								    .substr($isbn,4,5)."-"
								    .substr($isbn,9,1);
								break;
						default: return false; break;
					endswitch;
					}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>This is the collection of ISBN code I&#8217;m actively using, compiled from the original code and the comments.</p>
<p>I added the isnb_dashes($isbn) function, which accepts a 10 or 13 digit ISBN number and adds the dashes. This does not check the validity of the string, it just returns it.  If it isn&#8217;t 10 or 13 characters long, the function returns false.</p>
<p><code><br />
function isbn_convert($isbn) {<br />
        $isbn2 = substr("978" . trim($isbn), 0, -1);<br />
        $sum13 = isbn_genchksum13($isbn2);<br />
        $isbn13 = "$isbn2-$sum13";<br />
        return ($isbn13);<br />
    }</p>
<p>function isbn_gettype($isbn) {<br />
        $isbn = trim($isbn);<br />
        if (preg_match('%[0-9]{12}?[0-9Xx]%s&#8217;, $isbn)) {<br />
            if (isbn_validatettn($isbn)==1){<br />
                    return 13;<br />
                       } else {return(-1);}</p>
<p>                } else if (preg_match(&#8217;%[0-9]{9}?[0-9Xx]%s&#8217;, $isbn)) {<br />
              if (isbn_validateten($isbn)==1){<br />
                    return 10;<br />
                       } else {return -1;}<br />
        } else {<br />
            return -1;<br />
        }<br />
    }</p>
<p>function isbn_validateten($isbn) {<br />
        $isbn = trim($isbn);<br />
        $chksum = substr($isbn, -1, 1);<br />
        $isbn = substr($isbn, 0, -1);<br />
        if (preg_match(&#8217;/X/i&#8217;, $chksum)) { $chksum=&#8221;10&#8243;; }<br />
        $sum = isbn_genchksum10($isbn);<br />
        if ($chksum == $sum){<br />
            return 1;<br />
        }else{<br />
            return 0;<br />
        }<br />
    }</p>
<p>function isbn_validatettn($isbn) {<br />
        $isbn = trim($isbn);<br />
        $chksum = substr($isbn, -1, 1);<br />
        $isbn = substr($isbn, 0, -1);<br />
        if (preg_match(&#8217;/X/i&#8217;, $chksum)) { $chksum=&#8221;10&#8243;; }<br />
        $sum = isbn_genchksum13($isbn);<br />
        if ($chksum == $sum){<br />
            return 1;<br />
        }else{<br />
            return 0;<br />
        }<br />
    }</p>
<p>function isbn_genchksum13($isbn) {<br />
        $t = 2;<br />
        $isbn = trim($isbn);<br />
                $b=0;<br />
                for($i = 1; $i genchksum10($isbn2);<br />
        if ($sum10==10) {$sum10=&#8217;X';}<br />
        $isbn10 = $isbn2.$sum10;<br />
        return ($isbn10);<br />
    }</p>
<p>## ISBN Add Dashes<br />
function isbn_dashes($isbn) {<br />
        switch(strlen($isbn)):<br />
				    case 13:<br />
						    return<br />
								    substr($isbn,0,3).&#8221;-&#8221;<br />
								    .substr($isbn,3,1).&#8221;-&#8221;<br />
								    .substr($isbn,4,3).&#8221;-&#8221;<br />
								    .substr($isbn,7,5).&#8221;-&#8221;<br />
								    .substr($isbn,12,1);<br />
								break;<br />
				    case 10:<br />
						    return<br />
								    substr($isbn,0,1).&#8221;-&#8221;<br />
								    .substr($isbn,1,3).&#8221;-&#8221;<br />
								    .substr($isbn,4,5).&#8221;-&#8221;<br />
								    .substr($isbn,9,1);<br />
								break;<br />
						default: return false; break;<br />
					endswitch;<br />
					}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: huh</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-67520</link>
		<dc:creator>huh</dc:creator>
		<pubDate>Tue, 13 Feb 2007 06:04:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-67520</guid>
		<description>cannot get this working.
just including it throws:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /usr/home/www/htdocs/test/ISBN_script.php on line 11

so I changed public function to function and (not surprisingly)

Fatal error: Undefined class name 'self' in /usr/home/www/htdocs/test/ISBN_script.php on line 13</description>
		<content:encoded><![CDATA[<p>cannot get this working.<br />
just including it throws:</p>
<p>Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or &#8216;}&#8217; in /usr/home/www/htdocs/test/ISBN_script.php on line 11</p>
<p>so I changed public function to function and (not surprisingly)</p>
<p>Fatal error: Undefined class name &#8217;self&#8217; in /usr/home/www/htdocs/test/ISBN_script.php on line 13</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OracleHome</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-61204</link>
		<dc:creator>OracleHome</dc:creator>
		<pubDate>Wed, 31 Jan 2007 17:54:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-61204</guid>
		<description>Hi,

Thanks for producing this, I found a javascript version, but wanted a PHP version for my site.

This code has saved me a lot of time.

Thanks again!</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for producing this, I found a javascript version, but wanted a PHP version for my site.</p>
<p>This code has saved me a lot of time.</p>
<p>Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andras</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-43172</link>
		<dc:creator>andras</dc:creator>
		<pubDate>Sun, 14 Jan 2007 23:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-43172</guid>
		<description>One more time, sorry. I think the test should be :
if (preg_match(’%^[0-9]{13}$%s’, $isbn))</description>
		<content:encoded><![CDATA[<p>One more time, sorry. I think the test should be :<br />
if (preg_match(’%^[0-9]{13}$%s’, $isbn))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andras</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-42997</link>
		<dc:creator>andras</dc:creator>
		<pubDate>Sun, 14 Jan 2007 13:32:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-42997</guid>
		<description>I just realize that the question mark has no sense in : 
if (preg_match(’%[0-9]{13}?%s’, $isbn)) 
so it should be :
if (preg_match(’%[0-9]{13}%s’, $isbn))</description>
		<content:encoded><![CDATA[<p>I just realize that the question mark has no sense in :<br />
if (preg_match(’%[0-9]{13}?%s’, $isbn))<br />
so it should be :<br />
if (preg_match(’%[0-9]{13}%s’, $isbn))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andras</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-42963</link>
		<dc:creator>andras</dc:creator>
		<pubDate>Sun, 14 Jan 2007 11:45:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-42963</guid>
		<description>Hi,
thanks for this PHP port and for the useful comments. I wonder if there is a case where the check digit of a ISBN-13 could be 'x' or 'X'. From this page : http://en.wikipedia.org/wiki/ISBN#Check_digit_in_ISBN_13 I think it's impossible. It can only be a decimal  digit from 0 to 9.

So, if I'm right, the isbn_gettype should be :
function isbn_gettype($isbn) {
        $isbn = trim($isbn);
        if (preg_match('%[0-9]{13}?%s', $isbn)) {
            if (isbn_validatettn($isbn)==1){
                    return 13;
                       } else {return(-1);}
 
                } else if (preg_match('%[0-9]{9}?[0-9Xx]%s', $isbn)) {
              if (isbn_validateten($isbn)==1){
                    return 10;
                       } else {return -1;}
        } else {
            return -1;
        }
    }

and the isbn_validatettn function should be :

function isbn_validatettn($isbn) {
        $isbn = trim($isbn);
        $chksum = substr($isbn, -1, 1);
        $isbn = substr($isbn, 0, -1);
        $sum = isbn_genchksum13($isbn);
        if ($chksum == $sum){
            return 1;
        }else{
            return 0;
        }
    }</description>
		<content:encoded><![CDATA[<p>Hi,<br />
thanks for this PHP port and for the useful comments. I wonder if there is a case where the check digit of a ISBN-13 could be &#8216;x&#8217; or &#8216;X&#8217;. From this page : <a href="http://en.wikipedia.org/wiki/ISBN#Check_digit_in_ISBN_13" rel="nofollow">http://en.wikipedia.org/wiki/ISBN#Check_digit_in_ISBN_13</a> I think it&#8217;s impossible. It can only be a decimal  digit from 0 to 9.</p>
<p>So, if I&#8217;m right, the isbn_gettype should be :<br />
function isbn_gettype($isbn) {<br />
        $isbn = trim($isbn);<br />
        if (preg_match(&#8217;%[0-9]{13}?%s&#8217;, $isbn)) {<br />
            if (isbn_validatettn($isbn)==1){<br />
                    return 13;<br />
                       } else {return(-1);}</p>
<p>                } else if (preg_match(&#8217;%[0-9]{9}?[0-9Xx]%s&#8217;, $isbn)) {<br />
              if (isbn_validateten($isbn)==1){<br />
                    return 10;<br />
                       } else {return -1;}<br />
        } else {<br />
            return -1;<br />
        }<br />
    }</p>
<p>and the isbn_validatettn function should be :</p>
<p>function isbn_validatettn($isbn) {<br />
        $isbn = trim($isbn);<br />
        $chksum = substr($isbn, -1, 1);<br />
        $isbn = substr($isbn, 0, -1);<br />
        $sum = isbn_genchksum13($isbn);<br />
        if ($chksum == $sum){<br />
            return 1;<br />
        }else{<br />
            return 0;<br />
        }<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SVCHRE2ur3</title>
		<link>http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-42255</link>
		<dc:creator>SVCHRE2ur3</dc:creator>
		<pubDate>Fri, 12 Jan 2007 10:24:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.blyberg.net/2006/04/05/php-port-of-isbn-1013-tool/#comment-42255</guid>
		<description>Hi! Very nice site! Thanks you very much! qfEIKafpsRX</description>
		<content:encoded><![CDATA[<p>Hi! Very nice site! Thanks you very much! qfEIKafpsRX</p>
]]></content:encoded>
	</item>
</channel>
</rss>
