Replies: 3 comments 5 replies
-
The C# compiler is right. The emoji actually consists of two characters. The string To represent this emoji, you need to use the struct |
Beta Was this translation helpful? Give feedback.
-
Are you asking for the .NET runtime In the meantime, this has the benefit of working today and having possibly even preferable semantics: public string Glyph { get; } = "🧙🏼"; |
Beta Was this translation helpful? Give feedback.
-
Putting those details aside, I think the core confusion, especially for new generation developers, is the keyword As old dogs, we know it originated from C, when English character sets were the only ones used, and We are pretty much stuck. If trying to solve it some how, I'd wish a design that the C# language is not coupled to encoding. It would be better to leave those UTF-16/UTF-8 concepts to libraries. Yes, UTF-8 looks like the one true choice today, but so did UTF-16, and so did ASCII. 🤷 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Using emoji as character literals doesn't always seem to work:
This gives a compile error: CS1012 Too many characters in character literal.
However there is only one character (the wizard emoji). I guess certain emoji count as multiple characters? It would be nice if character literals could support those emoji.
Beta Was this translation helpful? Give feedback.
All reactions