- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
有谁知道以 PHP、Perl 或 Python(或任何其他语言,我可以轻松转换代码)作为开源/免费软件提供的 ISO 3779 车辆 VIN 解码器库?
即使只是解码 WMI 部分(前 3 个位置)也会节省我很多时间。提前致谢。
最佳答案
我会让您从维基百科抓取数据,但下面是一个您可以扩展的快速(模块化)示例(完成 WMI->Init()
方法)。我也可能将 VINLookup
类设为单例或将 WMI 分解到数据库中(在某处规范化数据并将其视为 base-33 数字,就像我[可能])。
// http://en.wikipedia.org/wiki/Vehicle_identification_number#World_Manufacturer_Identifier
define('VIN_CHARACTERS', 'ABCDEFGHJKLMNPRSTUVWXYZ1234567890'); // no I, O or Q & 0 is last.
class WMI
{
public $country;
public $region;
public $low;
public $high;
public function __construct($country,$region,$low,$high)
{
$this->country = $country;
$this->region = $region;
$this->low = $low;
$this->high = $high;
}
private static function CodeToDec($code)
{
if (strlen($code) != 2)
return false;
return (strpos(VIN_CHARACTERS, $code{0}) * strlen(VIN_CHARACTERS)) + strpos(VIN_CHARACTERS, $code{1});
}
public function IsMatch($vin)
{
// first, grab the first 2 characters
$code = substr($vin,0,2);
// next, see if it's in range
// we do this by converting it to a numeric
$_low = WMI::CodeToDec($this->low);
$_high = WMI::CodeToDec($this->high);
$_code = WMI::CodeToDec($code);
return (($_code >= $_low) && ($_code <= $_high));
}
public function __toString()
{
return sprintf("%s, %s (%s, %s)", $this->country, $this->region, $this->low, $this->high);
}
}
class VINLookup
{
private $vin;
private $wmis = array();
public function __construct($vin)
{
if (!VINLookup::IsValid($vin))
throw new Exception('Invalid VIN specified');
$this->vin = $vin;
$this->Init();
}
private function Init()
{
$this->wmis = array(
new WMI('South Africa', 'Africa', 'AA', 'AH'),
new WMI('Ivory Coast', 'Africa', 'AJ', 'AN'),
new WMI('(not assigned)', 'Africa', 'AP', 'A0'),
new WMI('Angola', 'Africa', 'BA', 'BE'),
new WMI('Kenya', 'Africa', 'BF', 'BK'),
new WMI('United States', 'North America', '1A', '10'),
new WMI('Canada', 'North America', '2A', '20'),
new WMI('Mexico', 'North America', '3A', '3W'),
new WMI('Costa Rica', 'North America', '3X', '37'),
);
}
public function GetCountry()
{
foreach ($this->wmis as $wmi)
{
if ($wmi->IsMatch($this->vin))
return $wmi;
}
return false;
}
public static function IsValid($vin)
{
return preg_match('/^[A-HJ-NPR-Z0-9]{17}$/',$vin);
}
}
用法:
// check for a valid VIN number supplied
VINLookup::IsValid(<vin>);
// create a new VINLookup with the specified VIN
$lookup = new VINLookup(<vin>);
// retrieve the _Country_ object (above), or FALSE if no country match was found.
$lookup->GetCountry();
关于php - PHP 中的 ISO 3779 车辆 VIN 解码器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6206954/
我想知道是否可以通过 ISO 8583 做一个完整的声明(在一个日期范围之间),我看到 ATM 可以做完整的声明并且想知道他们使用什么方法。我知道余额查询和迷你报表可以在超过 8583 的 POS 设
我一直在尝试通过 7zip 和 WinRar 提取 ISO 镜像。 这是我使用的命令行: 7z x -y "%Isocontents%\ISO.iso" -o%Newfolder% WinRar.ex
我正在将 ICU 集成到一些内部软件中。我希望能够获取诸如“en_US”之类的字符串并为其获取脚本名称“Latin”。 (虽然最终我实际上想要一个 ICU ScriptCode。) 我尝试使用 ICU
我的数据位于一个数据框中,其结构如下: df2 <- data.frame(Year = c("2007"), Week = c(1:12), Measurement = c(rnorm(12, me
我需要计算一周分配到的年份。例如,2003 年 12 月 29 日被指定为 2004 年的第一周(我认为这仅适用于欧洲)。您可以使用以下代码来查看: SELECT DATEPART(isowk, '2
我想做什么? 我想提取 ISO 文件并编辑其中的文件,然后将其重新打包回 ISO 文件。 (正如你已经读过的) 我为什么要这样做? 我想开始修改 PSP ISO,为此我必须使用游戏资源、 Assets
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 2年前关闭。 Improve this questi
我有一个文件。在 Python 中,我想占用它的创建时间,并将其转换为 ISO time (ISO 8601) string 同时保留它是在 Eastern Time Zone 中创建的事实。 (美国
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我在二维网格上有两个标量场。我想为第一个标量场绘制一条等值线,并根据第二个标量场设置其不透明度。 我从 this SO answer 开始尝试使用 mayavi但我无法从 3D 切换到 2D。 下面是
假设您声明两个同构 showing :: (Read a, Show a) => Iso' String a showing = iso read show reading :: (Read a, S
已关闭。此问题旨在寻求有关书籍、工具、软件库等的建议。不符合Stack Overflow guidelines准则。它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,
假设有一个两个字符的String,它应该代表ISO 639国家或语言名称。 你知道,Locale类有两个函数 getISOLanguages和 getISOCountries分别返回包含所有 ISO
实体中的值是否可以自由嵌入到 ISO 10303-21 格式的文件中? 在我看到的所有由 CAD 程序生成的示例中,length_measure 都嵌入在uncertainty_measure_wit
是否可以从原始 ISO 自动创建用于操作系统安装的 Vagrant .box 文件? 对我来说,Vagrant 提供的虚拟机上操作系统安装和配置的端到端自动化存在巨大差距。 当然,VagrantBox
有没有办法实现这样的格式: 2003-09-25T14:00:00.000+1000 or 2003-09-25T14:00:00.000+1100 要这样转换 2003-09-25T14:00:00
我正在使用: @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @JsonFormat( pattern = "MM-dd-yyyy" ) private
我需要将 iso-3166-1/iso-3166-2 代码转换为经度/纬度 例子: 输入:“美国”,输出:(37.09024, -95.71289100000001)。 输入“VE-O”,输出:(10
我想转换 POSIX 语言环境名称,例如 en_US、de_DEISO-639-1 和 ISO-3166 代码到 Windows English_United States、German_German
我在 MS Access 上有一个数据库,我通过调用 PDO 和 odbc 驱动程序将其与 PHP 一起使用。我的数据库中有法语、丹麦语和波兰语单词。法语和丹麦语没问题,但波兰语字符没办法,我只得到“
我是一名优秀的程序员,十分优秀!