Fix to correctly handle characters larger than 16 bits.