added UTF-8 test, improved utf8_encode