major refactoring into utf8check.h