Comments (10)
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 ?? "")")
}
from mtbbarcodescanner.
@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
}
from mtbbarcodescanner.
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!
from mtbbarcodescanner.
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.
from mtbbarcodescanner.
Thanks for such a quick response and your input!
Keep up the great work!
from mtbbarcodescanner.
@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.
from mtbbarcodescanner.
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.
from mtbbarcodescanner.
I just ran into a Hyundai VIN that includes a slash (/) in position 18. According to standards, that is not a legal US VIN.
from mtbbarcodescanner.
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 :-/.
from mtbbarcodescanner.
Thats just lovely. :(
from mtbbarcodescanner.
Related Issues (20)
- Only works with iOS10+ after recent changes HOT 2
- Impossible to read CODABAR barcode HOT 1
- Disable rotation HOT 1
- Initial camera setting HOT 1
- Warnings HOT 4
- Call stopScanning crash in viewDidDisappear HOT 4
- Flutter + Xcode 8.0: 3 errors, 9 warnings HOT 1
- Catalyst Support? HOT 4
- Maximum of read multiple codes HOT 3
- Problem configurating scanner with QR and Barcode HOT 5
- output becomes Garbled text HOT 8
- Crash NSInvalidArgumentException *** -[AVCaptureMetadataOutput setMetadataObjectTypes:] Unsupported type found - use -availableMetadataObjectTypes HOT 3
- when barcode data increased it is difficult to read Code.. HOT 1
- UIView preview has issues during orientation changes HOT 6
- Define Barcodetype in Swift HOT 3
- Camera Unfreeze method not working on. HOT 3
- Unrecognized Barcode Style HOT 1
- Camera unfreeze is corrupting flash HOT 3
- Getting the bytes raw HOT 1
- It's crashing on iPad and iPhone after you try to scan QR code. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtbbarcodescanner.