encoding fixes for GHC HEAD