Closed Daltron closed 9 years ago
Hey @dhint4. I did some research, and it looks like the leading I
character stands for "import". I think you posted a capital L, but I believe it's actually a capital i. At least that's what I found after digging.
From a VIN-scanner manufacturers website:
Worth Data provides special support for reading the VIN's, including through the windshield. Our readers also allow suppressing the "I" on imports' VINs.
There's also a SourceForge thread with people discussing the issue.
It looks like the general consensus is that you should strip the I
character if and only if the VIN number is longer than 17 characters. If you do that, you should be able to parse all of the codes correctly.
Since this most likely happens in all barcode scanners, I'm going to close this for now. If you test this with other scanners and find MTBBarcodeScanner is producing different results, I would suggest reporting back.
Thanks!
Thanks for such a quick response and your input!
Keep up the great work! :+1:
I know it is a little late, apologize, but some additional info for folks that might come by: Code39 barcode for vins can have 17,18,19, and 20 chrs depending on the manufacturer. 17 - good to go 18 - strip first chr 19 - strip first & last chr 20 - strip first 2 & last chr
Swift 4 code snippet:
var vin: String?
let stringValue = code.stringValue!
if code.type.rawValue == "org.iso.Code39" {
if stringValue.count == 18 {
vin = String(stringValue.suffix(17))
} else if stringValue.count == 19 {
vin = String(stringValue.suffix(18).prefix(17))
} else if stringValue.count == 20 {
vin = String(stringValue.suffix(18).prefix(17))
} else {
vin = stringValue
}
print("Adjusted Vin: \(vin ?? "")")
}
@stephenfeather Even later. This RegEx string has worked well for me:
struct RegexString {
static let vin = "[A-HJ-NPR-Z0-9]{17}"
}
And usage:
let range = vinString.range(of: RegexString.vin, options: [.regularExpression, .caseInsensitive])
var extractedVin: String?
if let matchRange = range {
extractedVin = String(vinString[matchRange.lowerBound..<matchRange.upperBound])
} else {
return
}
@stephenfeather I know I'm late to this party but thank you for that detailed run down of possible codes. Do you have any supporting docs for that? I can't find anything that details VIN's with with more than 17 characters encoded, even though there's obviously cases where the barcode contains more than 17 characters.
USG: https://www.nhtsa.gov/DOT/NHTSA/Rulemaking/Rules/Associated%20Files/VIN_Final_Rule_April_08.pdf
This is how the 17 spaces are to be used to create a valid VIN. Any chars outside those 17 are extraneous and can be dropped.
Just wanted to add a recent discovery: I have been finding Hyundai VINs including a trailing hyphen, so yet another variant to watch out for that does not comply with @stephenfeather's Swift snippet.
I just ran into a Hyundai VIN that includes a slash (/) in position 18. According to standards, that is not a legal US VIN.
I just ran into a Hyundai VIN that includes a slash (/) in position 18. According to the Wiki page Vehicle Identification Numbers (VIN codes)/Hyundai/VIN Codes -- at least as of 2016 -- they add positions 18 and 19, position 19 being used to encode Manufacturing Month.
The 49 CFR Part 565 regulations dictating VIN requirements specifies how a Vehicle Identification Number must be structured, but does not address anything about the content of an associated barcode. From what I have been able to ferret out, neither does ISO 3779:2009 standards specify it for international VINs.
So the printed VIN must comply with standard but apparently anything goes as far as what the barcode contains :-/.
Thats just lovely. :(
First off, great library!
The problem I am having is that when I read VIN barcodes from vehicles that are not in the QR format, it wants to throw a
l
in front of each vin at the very beginning. Everything after that is read in correctly but I'm not sure why it is throwing thatl
in at the beginning.Here is a sample that it does it on:
I have also did it on a vehicle that is owned by my family that is also not in the QR format and it did the exact same thing.
Any help would be appreciated!
Thanks