use header encoding as first priority