UnicodeEmojiNet 1.2.1

dotnet add package UnicodeEmojiNet --version 1.2.1
NuGet\Install-Package UnicodeEmojiNet -Version 1.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UnicodeEmojiNet" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UnicodeEmojiNet --version 1.2.1
#r "nuget: UnicodeEmojiNet, 1.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UnicodeEmojiNet as a Cake Addin
#addin nuget:?package=UnicodeEmojiNet&version=1.2.1

// Install UnicodeEmojiNet as a Cake Tool
#tool nuget:?package=UnicodeEmojiNet&version=1.2.1

UnicodeEmojiNet

Introduction

UnicodeEmojiNet allows to simply retrieve all Unicode emojis with their name and categories in C# either get them as a JSON string or as custom objects in a List.

Features ⭐

  • Retrieve Emojis: Retrieve emojis from the Unicode website.
    • As JSON string or as custom objects in a list
  • Retrieve emoji categories: Get all available categories (main and sub)
    • As custom objects in a list

Usage 🔧

Constructor

Initialize the EmojiManager using the constructor:

EmojiManager emojiManager = new EmojiManager(string operatingFolder, bool skipAdditional);
What does skipAdditional do?

If skipAdditional is set to true, only the main-list will be queried and processed (which is https://unicode.org/emoji/charts/full-emoji-list.html), the other list(s) won't be because they "only" contain variations like all skin tones, the main list only contains the yellow tone.

Code

Here are all things you can do right now:

Check if html source files are present in operatingFolder:

This method checks if the needed html files are present and returns true or false.

bool AreHtmlFilesPresent = emojiManager.AreSourcesPresent();
Download html source files and process:

Before you can do anything else, call this so (the files are processed and) everything is done. But if this was called once and the files are present, you are good to go.

emojiManager.DownloadAndProcessFiles();
Get all emoji categories as list:

Get all "MainCategories" (like "Animals" etc.) and their "SubCategories" (like "marine" etc.) which are inside the main ones.

List<EmojiCategory> AllCategories = emojiManager.GetAllCategories();
Give the JSON back as string:

Get the JSON as string object.

string EmojiListAsJson = emojiManager.GetEmojiListAsJsonString();
Give the json back as List<EmojiInfo>:

Get the emojis as List<EmojiInfo>.

List<EmojiInfo> EmojiList = emojiManager.GetEmojiList();
Example code:

Here is a example snippet to use the code.

static async Task Main(string[] args)
{
    EmojiManager emojiManager = new("/Users/YourUser/Desktop/", false);

    if (emojiManager.AreSourcesPresent())
    {
        await emojiManager.DownloadAndProcessFiles();

        string x = await emojiManager.GetEmojiListAsJsonString();
        await File.WriteAllTextAsync(Path.Combine("/Users/YourUser/Desktop/", "unicode-emojis.json"), x, Encoding.UTF8);
    }
}

How to skip/speed-up source download:

  • You can download them yourself and put them in a folder
  • You can download them, pack them in a binary and copy them in a certain folder

.. you get it..

Types 🔖

  • EmojiInfo: The emoji itself

    • Id (a running number given by unicode) - int
    • Value (the emoji character) - string
    • Name (the name) - string
    • IsRecentlyAdded (is it a newly added emoji?) - bool
    • MainCategory (like animals) - string
    • SubCategory (like marine-animals) - string
  • EmojiCategory: A category in which emojis are sorted in

    • CategoryName (this is the name of the main-category) - string
    • SubCategories (the names of all sub-categories under this main-category) - string[]

Example projects

  • EmojiSearchEngine (simple light blazor wasm example which I needed to create this library for)

FAQ

Q: How do you expect me to use this when it needs to download the html files?

A: I will think of something to make it easier, but for now you could download them yourself and them deliver them with your file and copy them to a "operatingFolder".

To-Do

  • Implement some caching and/or a faster way to download everything

License 📜

UnicodeEmojiNet is licensed under the GNU General Public License v3.0.

You can read the full license details of the GNU General Public License v3.0 here.

Icon

The icon was created by uxwing.com, found here: https://uxwing.com/smiling-line-icon/

Disclaimer and Acceptance ⚠️

By using this library, you acknowledge that you have read and understood the full disclaimer in the DISCLAIMER.md file and accept its terms. Additionally, you agree to abide by the GNU General Public License v3.0 under which UnicodeEmojiNet is licensed, regardless of whether you have read the license text.

Please be aware that the author of the project and the project itself are not endorsed by Unicode and do not reflect the views or opinions of Unicode or any individuals officially involved with the project. The author of this library is not responsible for any incorrect or inappropriate usage. Please ensure that you use this library in accordance with its intended purpose and guidelines.

The newest ReadMe and the repository can be found here
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 73 4/30/2024
1.2.0 67 4/29/2024
1.1.0 70 4/26/2024
1.0.0 80 4/25/2024

ReadMe update and removed ToString() from EmojiInfo