<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fa">
	<id>https://www.iran-pedia.org/w/index.php?action=history&amp;feed=atom&amp;title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86%3ACheck_isxn</id>
	<title>پودمان:Check isxn - تاریخچهٔ نسخه‌ها</title>
	<link rel="self" type="application/atom+xml" href="https://www.iran-pedia.org/w/index.php?action=history&amp;feed=atom&amp;title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86%3ACheck_isxn"/>
	<link rel="alternate" type="text/html" href="https://www.iran-pedia.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Check_isxn&amp;action=history"/>
	<updated>2026-04-05T19:36:16Z</updated>
	<subtitle>تاریخچهٔ نسخه‌ها برای این صفحه در ویکی</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://www.iran-pedia.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Check_isxn&amp;diff=21582&amp;oldid=prev</id>
		<title>Mahan: ۱ نسخه واردشده</title>
		<link rel="alternate" type="text/html" href="https://www.iran-pedia.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Check_isxn&amp;diff=21582&amp;oldid=prev"/>
		<updated>2017-12-25T21:34:01Z</updated>

		<summary type="html">&lt;p&gt;۱ نسخه واردشده&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;fa&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;→ نسخهٔ قدیمی‌تر&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;نسخهٔ ‏۲۵ دسامبر ۲۰۱۷، ساعت ۲۳:۳۴&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;fa&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(بدون تفاوت)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mahan</name></author>
	</entry>
	<entry>
		<id>https://www.iran-pedia.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Check_isxn&amp;diff=21581&amp;oldid=prev</id>
		<title>Mahan در ‏۳۰ ژوئیهٔ ۲۰۱۶، ساعت ۰۶:۱۰</title>
		<link rel="alternate" type="text/html" href="https://www.iran-pedia.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Check_isxn&amp;diff=21581&amp;oldid=prev"/>
		<updated>2016-07-30T06:10:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحهٔ تازه&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This template is a copy of the ISXN validation code from [[Module:Citation/CS1]]&lt;br /&gt;
-- which allows for validating ISBN, ISMN, and ISSN without invoking a citation template&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; IS _ V A L I D _ I S X N &amp;gt;-----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().&lt;br /&gt;
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,&lt;br /&gt;
spaces and other non-isxn characters.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_valid_isxn (isxn_str, len)&lt;br /&gt;
	local temp = 0;&lt;br /&gt;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values &amp;#039;0&amp;#039; → 0x30 .. &amp;#039;9&amp;#039;  → 0x39, &amp;#039;X&amp;#039; → 0x58&lt;br /&gt;
	len = len+1;							-- adjust to be a loop counter&lt;br /&gt;
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum&lt;br /&gt;
		if v == string.byte( &amp;quot;X&amp;quot; ) then		-- if checkdigit is X (compares the byte value of &amp;#039;X&amp;#039; which is 0x58)&lt;br /&gt;
			temp = temp + 10*( len - i );	-- it represents 10 decimal&lt;br /&gt;
		else&lt;br /&gt;
			temp = temp + tonumber( string.char(v) )*(len-i);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return temp % 11 == 0;					-- returns true if calculation result is zero&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; IS _ V A L I D _ I S X N  _ 1 3 &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.&lt;br /&gt;
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length&lt;br /&gt;
and stripped of dashes, spaces and other non-isxn-13 characters.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_valid_isxn_13 (isxn_str)&lt;br /&gt;
	local temp=0;&lt;br /&gt;
	&lt;br /&gt;
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values &amp;#039;0&amp;#039; → 0x30 .. &amp;#039;9&amp;#039;  → 0x39&lt;br /&gt;
	for i, v in ipairs( isxn_str ) do&lt;br /&gt;
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit&lt;br /&gt;
	end&lt;br /&gt;
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C H E C K _ I S B N &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Determines whether an ISBN string is valid&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function check_isbn( isbn_str, error_string )&lt;br /&gt;
	if nil ~= isbn_str:match(&amp;quot;[^%s-0-9X]&amp;quot;) then -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X&lt;br /&gt;
		return error_string;&lt;br /&gt;
	end&lt;br /&gt;
	isbn_str = isbn_str:gsub( &amp;quot;-&amp;quot;, &amp;quot;&amp;quot; ):gsub( &amp;quot; &amp;quot;, &amp;quot;&amp;quot; );	-- remove hyphens and spaces&lt;br /&gt;
	local len = isbn_str:len();&lt;br /&gt;
 &lt;br /&gt;
	if len ~= 10 and len ~= 13 then&lt;br /&gt;
		return error_string;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if len == 10 then&lt;br /&gt;
		if isbn_str:match( &amp;quot;^%d*X?$&amp;quot; ) == nil then &lt;br /&gt;
			return error_string; &lt;br /&gt;
		end&lt;br /&gt;
		return is_valid_isxn(isbn_str, 10) and &amp;#039;&amp;#039; or error_string;&lt;br /&gt;
	else&lt;br /&gt;
		local temp = 0;&lt;br /&gt;
		if isbn_str:match( &amp;quot;^97[89]%d*$&amp;quot; ) == nil then -- isbn13 begins with 978 or 979; ismn begins with 979&lt;br /&gt;
			return error_string; &lt;br /&gt;
		end&lt;br /&gt;
		return is_valid_isxn_13 (isbn_str) and &amp;#039;&amp;#039; or error_string;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C H E C K _ I S M N &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the&lt;br /&gt;
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf&lt;br /&gt;
section 2, pages 9–12.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function check_ismn (id, error_string)&lt;br /&gt;
	local text;&lt;br /&gt;
	local valid_ismn = true;&lt;br /&gt;
&lt;br /&gt;
	id=id:gsub( &amp;quot;[%s-–]&amp;quot;, &amp;quot;&amp;quot; );													-- strip spaces, hyphens, and endashes from the ismn&lt;br /&gt;
&lt;br /&gt;
	if 13 ~= id:len() or id:match( &amp;quot;^9790%d*$&amp;quot; ) == nil then					-- ismn must be 13 digits and begin 9790&lt;br /&gt;
		valid_ismn = false;&lt;br /&gt;
	else&lt;br /&gt;
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return valid_ismn and &amp;#039;&amp;#039; or error_string&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S S N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four&lt;br /&gt;
digits with a space.  When that condition occurred, the resulting link looked like this:&lt;br /&gt;
&lt;br /&gt;
	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can&amp;#039;t have spaces in an external link&lt;br /&gt;
	&lt;br /&gt;
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees&lt;br /&gt;
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn&lt;br /&gt;
error message.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function check_issn(id, error_string)&lt;br /&gt;
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate&lt;br /&gt;
	local text;&lt;br /&gt;
	local valid_issn = true;&lt;br /&gt;
&lt;br /&gt;
	if not id:match (&amp;#039;^%d%d%d%d%-%d%d%d[%dX]$&amp;#039;) then&lt;br /&gt;
		return error_string;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	id=id:gsub( &amp;quot;[%s-–]&amp;quot;, &amp;quot;&amp;quot; );									-- strip spaces, hyphens, and endashes from the issn&lt;br /&gt;
&lt;br /&gt;
	if 8 ~= id:len() or nil == id:match( &amp;quot;^%d*X?$&amp;quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position&lt;br /&gt;
		valid_issn=false;										-- wrong length or improper character&lt;br /&gt;
	else&lt;br /&gt;
		valid_issn=is_valid_isxn(id, 8);						-- validate issn&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return valid_issn and &amp;#039;&amp;#039; or error_string&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
------------------------------&amp;lt; E N T R Y   P O I N T S &amp;gt;--------------------------------------------------====&lt;br /&gt;
&lt;br /&gt;
function p.check_isbn(frame)&lt;br /&gt;
	return check_isbn(frame.args[1] or frame:getParent().args[1], frame.args[&amp;#039;error&amp;#039;] or frame:getParent().args[&amp;#039;error&amp;#039;] or &amp;#039;error&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.check_ismn(frame)&lt;br /&gt;
	return check_ismn(frame.args[1] or frame:getParent().args[1], frame.args[&amp;#039;error&amp;#039;] or frame:getParent().args[&amp;#039;error&amp;#039;] or &amp;#039;error&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.check_issn(frame)&lt;br /&gt;
	return check_issn(frame.args[1] or frame:getParent().args[1], frame.args[&amp;#039;error&amp;#039;] or frame:getParent().args[&amp;#039;error&amp;#039;] or &amp;#039;error&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Mahan</name></author>
	</entry>
</feed>