Skip to content

kurzdigital/mrzparser-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MRZ Parser for C/C++

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

How to use

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"

How to parse a MRZ

Then invoke parse_mrz() with a MRZ (the string may contain white space and/or line breaks):

MRZ mrz;
char line[1024];
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.

About

Single-file header library to parse a MRZ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published