correct handling of UTF-8 input