Ah, it looks like MRI uses rb_locale_str_new_cstr so it creates a string in the current locale. So not always UTF-8 so that is definitely wrong.