Character conversion relies on the setlocale(LC_TYPE, "") in main(), but maybe there are better ways of doing this.