evgeniylevakhin / Unidecode.NET

ASCII transliterations of Unicode text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unidecode.NET

Build status NuGet NuGet License MIT

Purpose

It often happens that you have text data in Unicode, but you need to represent it in ASCII. For example when integrating with legacy code that doesn’t support Unicode, or for ease of entry of non-Roman names on a US keyboard, or when constructing ASCII machine identifiers from human-readable Unicode strings that should still be somewhat intelligible (a popular example of this is when making an URL slug from an article title).

Overview

Unidecode is meant to be a transliterator of last resort, to be used once you've decided that you can't just display the Unicode data as is, and once you've decided you don't have a more clever, language-specific transliterator available or once you've already applied a smarter algorithm and now just want Unidecode to do cleanup.

In other words, when you don't like what Unidecode does, do it yourself. Really, that's what the above says. Here's how you would do this for German, for example:

In German, there's the typographical convention that an umlaut (the double-dots on: ä ö ü) can be written as an "-e", like with "Schön" becoming "Schoen". But Unidecode doesn't do that. Unidecode simply drop the umlaut accent and give back "Schon".

More information

Example code

Take a look at the list of assertions:

Assert.Equal("Rabota s kirillitsei", "Работа с кириллицей".Unidecode());
Assert.Equal("aouoAOUO", "äöűőÄÖŨŐ".Unidecode());
Assert.Equal("Hello, World!", "Hello, World!".Unidecode());
Assert.Equal("'\"\r\n", "'\"\r\n".Unidecode());
Assert.Equal("CZSczs", "ČŽŠčžš".Unidecode());
Assert.Equal("a", "".Unidecode());
Assert.Equal("a", "α".Unidecode());
Assert.Equal("a", "а".Unidecode());
Assert.Equal("chateau", "ch\u00e2teau".Unidecode());
Assert.Equal("vinedos", "vi\u00f1edos".Unidecode());

Other implementations

Credits

This project is a fork of the unidecodesharpfork written by Dima Stefantsov.

License

This project is licensed under MIT.

Character transliteration tables used in this project are converted from the tables provided in Unidecode for Python under the GPL-2.0 license which is port of the Perl library Text::Unidecode by Sean M. Burke and are distributed under the Perl license.

About

ASCII transliterations of Unicode text

License:MIT License


Languages

Language:C# 99.9%Language:Python 0.1%