Unicode characters in scanned Barcode Swift - ios

I have created one bar code scanner application and used AVFoundation native framework. Some of our barcode contains hidden unicode characters and we are unable to scan it. Here is an example of bar code:
]d201000000000010!0000-023
I am getting above code like: \u{1D}01000000000010\u{1D}0000-023
In above barcode ]d2 varies. I am unable to find type of the barcode. How can I parse that Unicode contained string into normal string? Does any one face this type of issue or barcode? Thanks in advance.

\u{1D}01000000000010\u{1D}0000-023 Looks to be a GS1-formatted barcode. Full spec is here And the values after the {1D} delimiter are call "application identifiers" and identify the type of data contained in that field. GS1 is really common in any industry where full supply-chain tracking is needed such as the medical device industry, etc. A concise list of application identifiers is here

Related

Print a code128C barcode pair

The bar code 128 subset C the number of digits should always be even.
How to print bar code with odd character? example:
1517072011170323703007607271023031701
Using DelhiXE7 and Fortes Report 4.0 VCL
Is this question related to finnish banking barcode ?
if YES: You must pad the data to be of even length, according to the documentation published by the bank. Switching the barcode encoding system is not allowed by the relevant banking standard.
reference URL: http://www.finanssiala.fi/maksujenvalitys/dokumentit/Bank_bar_code_guide.pdf
if NO: Just first encode the even-length part, then switch to code 128A or 128B using the encoding switching special "character" and finally encode the last digit using either 128A or 128B, whichever serves you better.

Extracting binary data from QR-code with zbar

I'm trying to extract binary data from QR-code with zbar (the QR-code was originally encoded using the iOS SDK passing a NSData object). Unfortunately the ZBarSymbol class only provides the content in a NSString member. Trying to extract a NSData from it using NSISOLatin1StringEncoding seems to work but still fails in some occasions.
I see in the zbar implementation that it is possible to access an object of type zbar_symbol_t that contains a pointer to char. By looking into it, it seems to contain the original content but with additional data of some kind, this is an example:
Original data: 9e7328c16bca3aaff532440917e4df6e155b96bd
Data in zbar_symbol_t: c29e7328c3816bc38a3ac2afc3b532440917c3a4c39f6e155bc296c2bd
Anyone who knows what is exactly that data in zbar_symbol_t, why it is different from data I originally placed in the QR-code and how it is possible, if possible at all, to extract my original data from that?
I am not sure what those bytes represent, probably zbar is trying to interprete the bytes as a UTF-8 string even though the QR is in byte mode.
Switching to zxing fixed everything, there is no interleaved unexpected byte and the raw data contains the entire QR code including the mode, terminator, padding etc... Also it seems to never fails, while zbar seemed to fail sometime.

GS1 barcode parsing

We need to parse the GS1 datamatrix barcode which will be provided by other party. We know they are going to use GTIN(01), lot number(10), Expiration date(17), serial number (21). The problems is that barcode reader output a string, the format is like this 01076123456789001710050310AC3453G321455777. Since there is not separator and both serial number and lot number are variable length according to GS1 standard, we have trouble to identify segments. My understanding is that it seems like the best way to parse is to embed the parser in the scanning device, not from the application. But we didn't plan an embed software yet. How can I implement the parser? Any suggestions?
There should be a FNC1 character at the end of a variable-length field that is not filled to maximum; so that FNC1 will appear between the G3 and the 21.
FNC1 is invisible to humans but can be detected by scanners and will be reproduced in the string reported by the scanner. Simply send the string directly to a text file and examine the text with a hex reader. the FNC1 should be obvious.
If you can, it might be an idea to swap the sequence of the 21 field and the 10 field since you appear to be using a pure-numeric for 21. This would make the barcode produced a little shorter.
One way to deal with this is to program the scanner to replace FNC1 with space or another plain text character before sending it to your application. The scanner manufacturer usually provides a tool to produce programming bar codes that can do simple substitutions in the scanner. Then you can parse the data without having to handle special characters.

Decoding Code128 barcodes?

I'm reading barcodes in an iOS app using the built-in barcode recognizer.
I scanned the barcode on a bottle of prescription medication. I'm expecting this barcode to resolve to a number that I can use to refer to a medication database. What iOS tells me is this:
type: org.iso.Code128
string value: xAAAJ5wEA
I checked the Wikipedia entry for "Code 128" but I'm still not sure how to decode the string further. I'm assuming it's a "Code Set C" value, but I don't see how to translate it into the series of decimal numbers I'm expecting.
Any help would be appreciated, thanks.
Code 128 is a compact one-dimensional barcode primarily used for alphanumeric barcodes. All 128 characters in ASCII are encoded.
In this case, your result is almost certainly a barcode encoding "xAAAJ5wEA". That barcode looks like this Code 128 barcode:
Prescription medication tend to encode a great deal of information. Possibly the customer record number, how many refills, what medication, etc. It can be used to pull up all information about the customer in the pharmacy computers. Precisely how this data is encoded will likely be based on the pharmacy policies. Therefore you will need to customize your software for each pharmacy.

what is %s and %d?

I am trying to learn iOs programming. and I suppose this is a bit of a reverse question.
I have just completed a tutorial on youtube using Xcode to create a simple iPhone app that will allow you to store, list and delete data from an SQLite3 database (as the app i want to produce will need a database).
However the bloke who put the video up didn't seem to explain 'why' he did what he did, so I am now trying to understand what each bit of code does
(I come from a PHP and SQL web programming background, so I understand accessing databases, calling data rows etc to show the content on a website.)
The one part of this iOs bit I don't quite understand is the %s and %d values used as they didn't seem to be declared anywhere.
The code is;
if(sqlite3_open([dbPathString UTF8String], &personDB)==SQLITE_OK) {
NSString *inserStmt = [NSString stringWithFormat:#"INSERT INTO PERSONS(NAME,AGE) values ('%s', '%d')",[self.nameField.text UTF8String],[self.ageField.text intValue]];
now %s and %d clearly get their values from the self.nameField and self.ageField. However that implies that I could only ever submit two values into a table? or are there other % for other values, but surely then there is a max of 26.
I would be grateful for any explanation you could give.
Also in addition, does anyone have any suggestions about other fully explained ways to learn to code for iOS? especially if you were a starter just learning iOS programming for a first time with limited C programming skills before hand.
The area i am looking for is to create an app that will store some text fields and an image, which either will be stored in a database and the image either in the database or as a link and appropriately named.
I'd like to be able to manipulate the image to resize it so it is optimised for the iPhone display (don't need a HD image in the APP)
Later I'd like to be able to work out how either upload the local database (sqlite3) file to a an online storage (either my own server or dropbox), or synchronise it to an SQL database (from initial looks just exporting the file would be better and embedding the images into a field would be better for this project, even though i know it is not the normal way of doing things)
%s and %d are format specifiers for a null-terminated array of characters and a signed 32-bit integer respectively. You can find the details about specifiers in the String Programming Guide. However, you should not format the string this way for a SQLite statement as it puts you at risk of SQL injection. Instead you should bind the values using ? and the appropriate sqlite3_bind* function. For your situation you would use sqlite3_bind_text for NAME and sqlite3_bind_int for AGE.
Have a look at the class reference:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html
Here are the string format specifiers:
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265
As you can see, %d is outputting an integer while %s is outputting a string.
Part 1:
The % convention "string format specifiers" is a common standard for string substitution.
They are not variables, but typed substitution placeholders.
%s --> string
%d --> number
Part 2:
You might check out the iTunes U course:
iPhone Application Programming '11
by Prof. Jan Borchers
https://itunes.apple.com/us/itunes-u/iphone-application-programming/id474416629
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
%s
Null-terminated array of 8-bit unsigned characters. Because the %s specifier causes the characters to be interpreted in the system default encoding, the results can be variable, especially with right-to-left languages. For example, with RTL, %s inserts direction markers when the characters are not strongly directional. For this reason, it’s best to avoid %s and specify encodings explicitly.
%d, %D
Signed 32-bit integer (int).
That is what is called a formatted string, basically, it is a way to inject values into a string. The character after the % sign is used to indicate the datatype that the value should be formatted as. In your case, %s is used to indicate a string value and %d is used to indicate a decimal integral value.
This type of string formatting is extremely common; many programming languages provide some mechanism for performing this type of string formatting and the formatting symbols are largely standardized. You can find a more information on the C++ website.

Resources