Single-file header library to parse a Machine Readable Zone (Type 1, 2 and 3, MRV A and B, France ID and Swiss driver license).
Before you include the header file in one C or C++ file, you need to define
MRZ_PARSER_IMPLEMENTATION
to create the implementation:
#define MRZ_PARSER_IMPLEMENTATION
#include "mrzparser.h"
Then invoke parse_mrz()
with a MRZ (the string may contain white space
and/or line breaks):
MRZ mrz;
if (!parse_mrz(&mrz, "I<UTOERIKSSON<<ANNA<MARIA<<<<…")) {
fprintf(stderr, "error: %s\n", mrz.error);
}
Now the structure mrz
holds the parsed values from the MRZ:
printf("document number: %s\n", mrz.document_number);
If parse_mrz()
was unsuccessful (returned 0), mrz
may still contain
some data depending on the nature of the error. It is guaranteed that
all members of the mrz
struct are always null-terminated even in case
of an error.