iphoneiosnsstringzbar-sdk

My qrcode scanner not able to scan specific URL containing special character


I am able to scan all qrcodes for the urls however some urls containing special characters such as "%20" are not getting scanned and it crashes the app. I am using ZBarSDK for scanning and ZBarReaderView is the scanner.

http://www.winlogisticsmedia.com/images/bigkmr%20end%20sale.jpg is the URL which when made on qrcode, my app crashes and it shows the below window.

Crash Window

P.S: One more thing is that I think on which I am getting the scanning report (text) is a nsstring. Is there any chance relating to it as its an string and the text consists of numerics and special characters?

crash report of thread


Solution

  • I was having the same issue. My app would crash when I would log the AVMetadataMachineReadableCodeObject stringValue.

    My original code that would crash:

    NSLog("%@", [machineReadableCodeObject stringValue]);
    

    Once I decoded the stringValue with stringByReplacingPercentEscapesUsingEncoding it does not crash anymore:

    NSString* decodedValue = [[machineReadableCodeObject stringValue] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSLog("%@", decodedValue);