GithubHelp home page GithubHelp logo

Comments (10)

stephenfeather avatar stephenfeather commented on July 26, 2024 11

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.

AdrianBinDC avatar AdrianBinDC commented on July 26, 2024 3

@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.

mikebuss avatar mikebuss commented on July 26, 2024 1

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.

stephenfeather avatar stephenfeather commented on July 26, 2024 1

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.

Daltron avatar Daltron commented on July 26, 2024

Thanks for such a quick response and your input!

Keep up the great work! 👍

from mtbbarcodescanner.

ptsteward avatar ptsteward commented on July 26, 2024

@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.

mijcon avatar mijcon commented on July 26, 2024

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.

EEaglehouse avatar EEaglehouse commented on July 26, 2024

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.

EEaglehouse avatar EEaglehouse commented on July 26, 2024

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.

stephenfeather avatar stephenfeather commented on July 26, 2024

Thats just lovely. :(

from mtbbarcodescanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.