fix a bug which can lead into an infinity loop.

it happens several times that 'unicode' is 0x00, and the app dead in that while(YES) loop.