<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>gb11643-1999 on adolsai's echo</title><link>https://adolsai.com/tag/gb11643-1999/</link><description>Recent content in gb11643-1999 on adolsai's echo</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Sat, 01 Mar 2014 11:11:36 +0800</lastBuildDate><atom:link href="https://adolsai.com/tag/gb11643-1999/index.xml" rel="self" type="application/rss+xml"/><item><title>GB11643-1999 &amp;amp; ISO 7064 verify function</title><link>https://adolsai.com/archives/31.html</link><pubDate>Sat, 01 Mar 2014 11:10:00 +0800</pubDate><guid>https://adolsai.com/archives/31.html</guid><description>&lt;p&gt;&lt;a href="http://blog.csdn.net/nsq122/article/details/6699002"&gt;http://blog.csdn.net/nsq122/article/details/6699002&lt;/a&gt;&#10;身份证校验位的计算/ISO 7064:1983.MOD 11-2 算法&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;&amp;lt;?&#10;function iso7064($vString)&#10;{&#10;// ISO 7064:1983.MOD 11-2&#10;// by goseaside@sina.com&#10;$wi = array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);&#10;$hash_map = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');&#10;$i_size = strlen($vString);&#10;$bModify = '?' == substr($vString, -1);&#10;$i_size1 = $bModify ? $i_size : $i_size + 1;&#10;for ($i = 1; $i &amp;lt;= $i_size; $i++) { &#10;$i1 = $vString[$i - 1] * 1;&#10;$w1 = $wi[($i_size1 - $i) % 10];&#10;$sigma += ($i1 * $w1) % 11; &#10;}&#10;if($bModify) return str_replace('?', $hash_map[($sigma % 11)], $vString);&#10;else return $hash_map[($sigma % 11)];&#10;}&#10;/*&#10;// Demo&#10;// $s 为某个 17 位身份证号码，不包含校验位&#10;echo iso7064($s); // 获得校验位的值&#10;echo iso7064(&amp;quot;$s?&amp;quot;); // 包含校验位的结果&#10;*/&#10;?&amp;gt;&#10;&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>