Use detected encoding

#4388