Giter Club home page Giter Club logo

Comments (12)

merih avatar merih commented on May 25, 2024 1

Actually the thing is, emoji.json in gemoji doesn't include \ufe0fΒ character at the end of such emojis. I don't know if that's an error in the data, but browsers and OS seem to render the emoji just fine without that character, however emoji regex separates the base from gender sequence.

Is this in the unicode spec, that emojis should be rendered correctly without fe0f, or browsers/OS trying their best?

from emoji-regex.

mathiasbynens avatar mathiasbynens commented on May 25, 2024

Can you post a code sample to reproduce the issue please? It seems to work for me:

const string = '\u{1F477}\u200D\u2640\uFE0F'; // 'πŸ‘·β€β™€οΈ'
console.log(string.match(emojiRegex())[0] === string);
// true

from emoji-regex.

duygualyzc avatar duygualyzc commented on May 25, 2024

I want to replace the matched emoji by wrapping it with an element. So my case is like this:

const text = 'πŸ‘·β€β™€οΈ'; // '\u{1F477}\u200D\u2640\uFE0F'
const replacedText = text.replace(emojiRegex(), (m) => {
   return '<span>' + m + '</span>';
});
console.log(replacedText);
// '<span>πŸ‘·</span>♀'

it separates the zwj sequences and matches just with πŸ‘·

from emoji-regex.

mathiasbynens avatar mathiasbynens commented on May 25, 2024

Which version of emoji-regex are you using? Your example works as expected in the latest version.

from emoji-regex.

duygualyzc avatar duygualyzc commented on May 25, 2024

Using v6.5.1. But I guess the problem is our emoji list which we got from gemoji When I converted the emojis to unicode, I realised that they don't include the gender part. I updated them with the correct ones, and the problem is solved.

Sorry for the hassle and thanks for your effort!

from emoji-regex.

mathiasbynens avatar mathiasbynens commented on May 25, 2024

emoji regex separates the base from gender sequence

Please provide a code example so I can reproduce this problem. The example in #27 (comment) seems to work fine.

from emoji-regex.

merih avatar merih commented on May 25, 2024
const text = "\u{1F477}\u200D\u2640";
console.log(text);
//> πŸ‘·β€β™€οΈ

const replacedText = text.replace(emojiRegex(), m => `<span>${m}</span>`);
console.log(replacedText);
//> <span>πŸ‘·</span>♀

from emoji-regex.

mathiasbynens avatar mathiasbynens commented on May 25, 2024

That’s the same example as before? It works as expected for me in the latest version: #27 (comment)

from emoji-regex.

merih avatar merih commented on May 25, 2024

Not really, the text is missing the last code point \ufe0f, does it still work as expected?

from emoji-regex.

mathiasbynens avatar mathiasbynens commented on May 25, 2024

Your input text doesn’t include \uFE0F, so why would you expect it in the output?

from emoji-regex.

merih avatar merih commented on May 25, 2024

Sorry if I wasn't clear enough. I wasn't expecting it to be in the output. The thing is, "\u{1F477}\u200D\u2640" when logged directly to the console, can produce the correct gendered emoji, however when passed through the regex, it doesn't take "\u2640" into account and only matches the male part.

const text = "\u{1F477}\u200D\u2640";
console.log(text);
//> πŸ‘·β€β™€οΈ 
// female construction worker, it's displayed properly without \uFE0F character

const replacedText = text.replace(emojiRegex(), m => `<span>${m}</span>`);
console.log(replacedText);
//> <span>πŸ‘·</span>♀
// only the male construction worker is matched with emoji regex,
// and ♀ (\u2640) character is left out

// which is basically "<span>\u{1F477}\u200D</span>\u2640"
// but I would expect it to be "<span>\u{1F477}\u200D\u2640</span>"

from emoji-regex.

highfeed avatar highfeed commented on May 25, 2024

Yes! I too have problem with a \uFE0F #29

from emoji-regex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.