How to make an emoji take up only 1 character for text length

Currently i have an emoji in my input text and different emojis take up different amount of space, from 1 to 5, i only want an emoji to take up 1 character. I’m using this great library for emojis that provides an access to unicode and an emoji image.

you can’t - emojis can be composed of various characters, because many are usually modifier, for example skin tone modifier, gender modifier etc
this was to avoid having too many unicode characters for emojis, as if you have 100 emojis, and then you want them in 5 different skin colors you have now 600 characters, instead having the modifier, the characters become 105 - and each emoji is made of one base character and one modifier

so, you can’t change how emojis are made.

What do i do then? its a terrible user experience

actually i just checked whatsapp and regardless of what emoji you type, it only takes up 1 character, so it can be done.

When it comes to the actual character count of the string, emoji will take up more than one character. If you are performing some action that shows a character count to a user, you can write your own logic to get that number. You can write regular expressions that find emoji and do your own, manual, counting.

1 Like

That’s brilliant! totally gonna do that