Additional character encoding fixes, not compatible with Ruby <2.0