Closed ritesh124 closed 8 years ago
Okay So after in details came to know this solution (http://stackoverflow.com/questions/22767584/ios7-barcode-scanner-api-adds-a-zero-to-upca-barcode-format)
Apple just convert every UPC-A barcode to EAN13 just by adding a leading zero.
The solution is to verify if the barcode is EAN13 and if the string result have a leading zero is safe to remove it and obtain a UPC-A barcode.
but i don't know where to add the code. Thanks in Advance
Solved By adding below code
let trimmedCode = readableCode.stringValue.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
print("trimmedCode: \(trimmedCode)\n\n")
// EAN or UPC?
// Check for added "0" at beginning of code.
let trimmedCodeString = "\(trimmedCode)"
var trimmedCodeNoZero: String
print("trimmedCode: \(trimmedCode)\n\n")
if trimmedCodeString.hasPrefix("0") && trimmedCodeString.characters.count > 1 {
trimmedCodeNoZero = String(trimmedCodeString.characters.dropFirst())
print(" if trimmedCodeNoZero has 0: \(trimmedCodeNoZero)\n\n")
// Send the doctored UPC to DataService.searchAPI()
} else {
// Send the doctored EAN to DataService.searchAPI()
print(" else trimmedCodeString: \(trimmedCodeString)\n\n")
}
The correct Barcode is 070177137069 but using RSBarcode it shows 0070177137069.