reapply utf8 fix by jag

I inadvertently rolled this back while removing windows carriage
returns. A test should be added for this functionality.