improve encoding for multibyte strings