Handle UTF-8 keys properly in match_similar.