Add bound checks to utf16_to_utf8
am: bce11021b2

Change-Id: Ic4995dee3763290f75b3ef623f257c71748d9d51