I am working on a simple java program that can take a string like this:
⛔️✋STOP✋⛔️ You've violated the law! But now... You
and replace each emoji with the appropriate java character. (I'm not sure what to call them).
Here is an example:
The automobile emoji: would be replaced with: "\\uD83D\\uDE97"
.
This allows me to have a string such as
"I am a car: \uD83D\uDE97"
in Java source code, and let it look like this:
I can easily do this for one type of emoji by doing this:
emojistring = emojistring.replace("", "\uD83D\uDE97");
The problem is I will be translating strings, like my example string, that will have lots of different types of emojjis.
I don't want to have to write a emojistring.replace("Emoji","Java Character")
for every single type of emoji that is in my string.
Is there an automatic way to detect an emoji in a string and replace it with the relevant java code?