Add bound checks to utf16_to_utf8 am: 0c9742db80 am: c0a1a3187c
am: d8d966fef5

Change-Id: If941a1348dc4c2533faa89b2bb90783fb77a853e