Çarşamba, 23 Mayıs 2018 / Published in Uncategorized

 

This slideshow requires JavaScript.

It is very common nowadays to express ourselves by using emojis. Instead of typing few words, we prefer to send one emoji that will express our feelings and emotions. Not sure that the other side will always get what we mean by sending a  , but that is another story.

In this article we will learn:

  1.  How to use emojis in static content like Labels and Buttons
  2.  How to define and use emoji in XAML only
  3.  How to define and use emoji using C#

Emoji?

Emoji is represented by a single unicode character or a specific sequence of unicode characters.

Example: is represented by U+1F914.

In case you wonder about the format the Unicode Preface briefly explains it:

..an individual Unicode value is expressed as U+nnnn, where nnnn is a four-digit number in hexadecimal notation..

In case of sequence, concat all the unicode characters without spaces. Some emojis use U+200D ZERO WIDTH JOINER between emoji to make them behave like a single, unique emoji character.

Example: ‍⚕️ is represented by U+1F468​ U+200D U+2695 U+FE0F

U+1F468 – manU+200D – ZWJU+2695 – medical symbol ⚕U+FE0F – variation selector

The full list of emojis can be found here.

Emoji in XAML

Since XAML  is an XML-based markup language, we have to use XML escape character &#; and we have to replace U+ prefix by x for each part of our emoji :

<!– ‍♂️ –>

<x:String x:Key=emojiManJuggling>&#x1F939;&#x200D;&#x2642;&#xFE0F;</x:String>

Example:

<Label Text={StaticResource emojiManJuggling} />
<!– Alternative, without resources –>

<Label Text=&#x1F939;&#x200D;&#x2642;&#xFE0F; />

If you need just a couple of emojis you may want to simply define all of them in XAML without involving any C# code at all.

Emoji in C#

Let’s define a class that will represent emoji:

public class Emoji

{

    readonly int[] codes;

    public Emoji(int[] codes)     {         this.codes = codes;     }

    public Emoji(int code)     {         codes = new int[] { code };     }

    public override string ToString()     {         if (codes == null)             return string.Empty;

        var sb = new StringBuilder(codes.Length);

        foreach (var code in codes)             sb.Append(Char.ConvertFromUtf32(code));

        return sb.ToString();     } }

It requires a single unicode character or sequence of characters as an input and simply overrides the ToString . Please note that U+ prefix should be replaced with 0x to specify hexadecimal notation.

Example of usage:

// person biking => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f6b4

Emoji bikingEmoji = new Emoji(0x1F6B4); //

// man technologist => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f468_200d_1f4bb

Emoji manTechnologiest = new Emoji(new int[] { 0x1F468, 0x200D, 0x1F4BB }); // ‍

Example:

$”I am going to {bikingEmoji}!

Conclusion

There are 2789 emojis available at the moment and this number is still in growth. Using emojis we can add more colours and a personal touch to our applications. So why not to use them ?

The source code is available on github.

P.S.: Please keep in mind that Apple may reject applications using emojis as part of UI, more information can be found here and here.

Published by Evgeny Zborovsky

.NET developer & Xamarin enthusiast

Published April 7, 2018April 9, 2018

Çarşamba, 23 Mayıs 2018 / Published in Uncategorized

 

This slideshow requires JavaScript.

It is very common nowadays to express ourselves by using emojis. Instead of typing few words, we prefer to send one emoji that will express our feelings and emotions. Not sure that the other side will always get what we mean by sending a  , but that is another story.

In this article we will learn:

  1.  How to use emojis in static content like Labels and Buttons
  2.  How to define and use emoji in XAML only
  3.  How to define and use emoji using C#

Emoji?

Emoji is represented by a single unicode character or a specific sequence of unicode characters.

Example: is represented by U+1F914.

In case you wonder about the format the Unicode Preface briefly explains it:

..an individual Unicode value is expressed as U+nnnn, where nnnn is a four-digit number in hexadecimal notation..

In case of sequence, concat all the unicode characters without spaces. Some emojis use U+200D ZERO WIDTH JOINER between emoji to make them behave like a single, unique emoji character.

Example: ‍⚕️ is represented by U+1F468​ U+200D U+2695 U+FE0F

U+1F468 – manU+200D – ZWJU+2695 – medical symbol ⚕U+FE0F – variation selector

The full list of emojis can be found here.

Emoji in XAML

Since XAML  is an XML-based markup language, we have to use XML escape character &#; and we have to replace U+ prefix by x for each part of our emoji :

<!– ‍♂️ –>

<x:String x:Key=emojiManJuggling>&#x1F939;&#x200D;&#x2642;&#xFE0F;</x:String>

Example:

<Label Text={StaticResource emojiManJuggling} />
<!– Alternative, without resources –>

<Label Text=&#x1F939;&#x200D;&#x2642;&#xFE0F; />

If you need just a couple of emojis you may want to simply define all of them in XAML without involving any C# code at all.

Emoji in C#

Let’s define a class that will represent emoji:

public class Emoji

{

    readonly int[] codes;

    public Emoji(int[] codes)     {         this.codes = codes;     }

    public Emoji(int code)     {         codes = new int[] { code };     }

    public override string ToString()     {         if (codes == null)             return string.Empty;

        var sb = new StringBuilder(codes.Length);

        foreach (var code in codes)             sb.Append(Char.ConvertFromUtf32(code));

        return sb.ToString();     } }

It requires a single unicode character or sequence of characters as an input and simply overrides the ToString . Please note that U+ prefix should be replaced with 0x to specify hexadecimal notation.

Example of usage:

// person biking => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f6b4

Emoji bikingEmoji = new Emoji(0x1F6B4); //

// man technologist => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f468_200d_1f4bb

Emoji manTechnologiest = new Emoji(new int[] { 0x1F468, 0x200D, 0x1F4BB }); // ‍

Example:

$”I am going to {bikingEmoji}!

Conclusion

There are 2789 emojis available at the moment and this number is still in growth. Using emojis we can add more colours and a personal touch to our applications. So why not to use them ?

The source code is available on github.

P.S.: Please keep in mind that Apple may reject applications using emojis as part of UI, more information can be found here and here.

Published by Evgeny Zborovsky

.NET developer & Xamarin enthusiast

Published April 7, 2018April 9, 2018

Çarşamba, 23 Mayıs 2018 / Published in Uncategorized

 

This slideshow requires JavaScript.

It is very common nowadays to express ourselves by using emojis. Instead of typing few words, we prefer to send one emoji that will express our feelings and emotions. Not sure that the other side will always get what we mean by sending a  , but that is another story.

In this article we will learn:

  1.  How to use emojis in static content like Labels and Buttons
  2.  How to define and use emoji in XAML only
  3.  How to define and use emoji using C#

Emoji?

Emoji is represented by a single unicode character or a specific sequence of unicode characters.

Example: is represented by U+1F914.

In case you wonder about the format the Unicode Preface briefly explains it:

..an individual Unicode value is expressed as U+nnnn, where nnnn is a four-digit number in hexadecimal notation..

In case of sequence, concat all the unicode characters without spaces. Some emojis use U+200D ZERO WIDTH JOINER between emoji to make them behave like a single, unique emoji character.

Example: ‍⚕️ is represented by U+1F468​ U+200D U+2695 U+FE0F

U+1F468 – manU+200D – ZWJU+2695 – medical symbol ⚕U+FE0F – variation selector

The full list of emojis can be found here.

Emoji in XAML

Since XAML  is an XML-based markup language, we have to use XML escape character &#; and we have to replace U+ prefix by x for each part of our emoji :

<!– ‍♂️ –>

<x:String x:Key=emojiManJuggling>&#x1F939;&#x200D;&#x2642;&#xFE0F;</x:String>

Example:

<Label Text={StaticResource emojiManJuggling} />
<!– Alternative, without resources –>

<Label Text=&#x1F939;&#x200D;&#x2642;&#xFE0F; />

If you need just a couple of emojis you may want to simply define all of them in XAML without involving any C# code at all.

Emoji in C#

Let’s define a class that will represent emoji:

public class Emoji

{

    readonly int[] codes;

    public Emoji(int[] codes)     {         this.codes = codes;     }

    public Emoji(int code)     {         codes = new int[] { code };     }

    public override string ToString()     {         if (codes == null)             return string.Empty;

        var sb = new StringBuilder(codes.Length);

        foreach (var code in codes)             sb.Append(Char.ConvertFromUtf32(code));

        return sb.ToString();     } }

It requires a single unicode character or sequence of characters as an input and simply overrides the ToString . Please note that U+ prefix should be replaced with 0x to specify hexadecimal notation.

Example of usage:

// person biking => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f6b4

Emoji bikingEmoji = new Emoji(0x1F6B4); //

// man technologist => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f468_200d_1f4bb

Emoji manTechnologiest = new Emoji(new int[] { 0x1F468, 0x200D, 0x1F4BB }); // ‍

Example:

$”I am going to {bikingEmoji}!

Conclusion

There are 2789 emojis available at the moment and this number is still in growth. Using emojis we can add more colours and a personal touch to our applications. So why not to use them ?

The source code is available on github.

P.S.: Please keep in mind that Apple may reject applications using emojis as part of UI, more information can be found here and here.

Published by Evgeny Zborovsky

.NET developer & Xamarin enthusiast

Published April 7, 2018April 9, 2018

Çarşamba, 23 Mayıs 2018 / Published in Uncategorized

 

This slideshow requires JavaScript.

It is very common nowadays to express ourselves by using emojis. Instead of typing few words, we prefer to send one emoji that will express our feelings and emotions. Not sure that the other side will always get what we mean by sending a  , but that is another story.

In this article we will learn:

  1.  How to use emojis in static content like Labels and Buttons
  2.  How to define and use emoji in XAML only
  3.  How to define and use emoji using C#

Emoji?

Emoji is represented by a single unicode character or a specific sequence of unicode characters.

Example: is represented by U+1F914.

In case you wonder about the format the Unicode Preface briefly explains it:

..an individual Unicode value is expressed as U+nnnn, where nnnn is a four-digit number in hexadecimal notation..

In case of sequence, concat all the unicode characters without spaces. Some emojis use U+200D ZERO WIDTH JOINER between emoji to make them behave like a single, unique emoji character.

Example: ‍⚕️ is represented by U+1F468​ U+200D U+2695 U+FE0F

U+1F468 – manU+200D – ZWJU+2695 – medical symbol ⚕U+FE0F – variation selector

The full list of emojis can be found here.

Emoji in XAML

Since XAML  is an XML-based markup language, we have to use XML escape character &#; and we have to replace U+ prefix by x for each part of our emoji :

<!– ‍♂️ –>

<x:String x:Key=emojiManJuggling>&#x1F939;&#x200D;&#x2642;&#xFE0F;</x:String>

Example:

<Label Text={StaticResource emojiManJuggling} />
<!– Alternative, without resources –>

<Label Text=&#x1F939;&#x200D;&#x2642;&#xFE0F; />

If you need just a couple of emojis you may want to simply define all of them in XAML without involving any C# code at all.

Emoji in C#

Let’s define a class that will represent emoji:

public class Emoji

{

    readonly int[] codes;

    public Emoji(int[] codes)     {         this.codes = codes;     }

    public Emoji(int code)     {         codes = new int[] { code };     }

    public override string ToString()     {         if (codes == null)             return string.Empty;

        var sb = new StringBuilder(codes.Length);

        foreach (var code in codes)             sb.Append(Char.ConvertFromUtf32(code));

        return sb.ToString();     } }

It requires a single unicode character or sequence of characters as an input and simply overrides the ToString . Please note that U+ prefix should be replaced with 0x to specify hexadecimal notation.

Example of usage:

// person biking => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f6b4

Emoji bikingEmoji = new Emoji(0x1F6B4); //

// man technologist => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f468_200d_1f4bb

Emoji manTechnologiest = new Emoji(new int[] { 0x1F468, 0x200D, 0x1F4BB }); // ‍

Example:

$”I am going to {bikingEmoji}!

Conclusion

There are 2789 emojis available at the moment and this number is still in growth. Using emojis we can add more colours and a personal touch to our applications. So why not to use them ?

The source code is available on github.

P.S.: Please keep in mind that Apple may reject applications using emojis as part of UI, more information can be found here and here.

Published by Evgeny Zborovsky

.NET developer & Xamarin enthusiast

Published April 7, 2018April 9, 2018

TOP