Set character encoding before writing any response (#11501)

Change-Id: I2a319d2b970d5d0953ece3717af17057c32f2041