Error using native smiles of Android in text field (Unity3d) -


i make application unity3d , build android, when write in input field android native smiles - got error in line

(invalid utf-16 sequence @ 1411555520 (missing surrogate tail)): r.font.requestcharactersintexture(chars, size, style); 

chars contains string contains native android smiles. how may support native smiles? use own class input field.

unfortunately, supporting emojis unity hard. when implemented feature, took month finish it, custom text layout engine , string class. so, if requirement not particularly important, suggest axing feature.

the reason behind particular error unity gets characters input string 1 one, , updates visual string every character. layman point of view, makes complete sense. however, doesn't take account how utf-16 encoding, used in c#, works.

utf-16 encoding uses 16 bits per single unicode characters. enough characters use. (and, every developer knows, "almost all" red flag lay dormant long time , explode , destroy love.) happens, emoji characters not fit 16 bit utf-16 character, , use special case — surrogate pair:

a table different characters in utf8 , utf16 representation

surrogate pair pair of utf-16 characters represent single unicode character. means don't have meaning on own individually, , when try render utf-16 character surrogate head or surrogate tail, can expect error this, or similar.

essentially, need implement kind of buffer, accept c# utf-16 characters 1 one, , pass them rendering code when verifies surrogate pairs closed.

oh, , forgot! emoji characters, country flags, represented two unicode characters. means can potentially take four utf-16 characters. aren't text encodings fun?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -