Skip to content

A .NET library to convert emojis to text and text to emojis. Supports the latest Unicode version.

License

Notifications You must be signed in to change notification settings

MeritonAliu/EmojiToText

Repository files navigation

EmojiToText

.NET NuGet Nuget License

Features

  • Convert emojis to descriptive text.
  • Convert text back into emojis.
  • XUnit tests are implemented
  • Supports the latest Unicode version 16.0

Installation

Install the package via NuGet:

dotnet add package EmojiToText

Or install it via Visual Studio NuGet package manager

Usage

Example usecases

  • Accessibility: Convert emojis to text for screen readers, improving content accessibility.
  • Text Processing: Enhance sentiment analysis or content moderation by converting emojis to readable text.
  • Debugging: Simplify logs with emojis by converting them to descriptive text for easier analysis.

Emoji to Text

using EmojiToText;

class Program
{
    static void Main(string[] args)
    {
        // Use this if your console does not support UTF-8
        Console.OutputEncoding = System.Text.Encoding.UTF8;

        string input = "Hello 😀!";
        string result = EmojiConverter.ToText(input);
        Console.WriteLine(result);  // Output: Hello grinning face!
    }
}

Text To Emoji

using EmojiToText;

class Program
{
    static void Main(string[] args)
    {
        // Use this if your console does not support UTF-8
        Console.OutputEncoding = System.Text.Encoding.UTF8;

        string text = "grinning face";
        string emoji = EmojiConverter.ToEmoji(text);
        Console.WriteLine(emoji);  // Output: 😀
    }
}

Running Tests

First clone the repository:

git clone https://github.com/MeritonAliu/EmojiToText.git

To run the tests for this project, use the following command:

dotnet test

Roadmap

The roadmap can be fount at: ROADMAP

Benchmarks

The following benchmarks apply to the current EmojiConverter methods. The mutlitple benchmarks are done with 1000 emojis/texts.

Method Mean Error StdDev Allocated
ConvertSingleEmojiToText 14.04 us 0.111 us 0.066 us 48 B
ConvertSingleTextToEmoji 10.61 us 0.307 us 0.203 us 32 B
ConvertMultipleEmojiToText 172.42 us 0.436 us 0.288 us -
ConvertMultipleTextToEmoji 500.84 us 1.132 us 0.749 us 6032 B

If you want to benchmark it yourself, clone the repo and use:

dotnet run --project Benchmark/EmojiToText.Benchmarks.csproj -c Release

References

Author

@MeritonAliu - 2024

Contributing

Bug reports and contributions are welcome! Feel free to submit pull requests or file issues.

License

Donation

If you want to support me and my work, feel free to donate a coffee

Buy me a coffee

About

A .NET library to convert emojis to text and text to emojis. Supports the latest Unicode version.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks