Reputation: 28497
I have to validate the user's emoji input and perform a comparison to see what they entered. However, I've started noticing that several emojis look identical, but are not equal. Take a look at the example below, moonA
has a length of 2, but moonB
is 3:
var moonA = "🌕";
var moonB = "🌕️";
console.log(moonA == moonB);
console.log("Moon A:", moonA.length);
console.log("Moon B:", moonB.length);
What could be causing this discrepancy? I've looked at them up close in both Windows and iOS, and they look exactly the same on both systems. Why are there two versions of the same emoji?
Upvotes: 2
Views: 199
Reputation: 362097
What Unicode character is this? identifies them as:
moonA = "🌕"
U+1F315 : FULL MOON SYMBOL
moonB = "🌕️"
U+1F315 : FULL MOON SYMBOL
U+FE0F : VARIATION SELECTOR-16 [VS16] {emoji variation selector}
Upvotes: 2