models: slightly refactor the unicode handling