Skip to content

fabslab/UnicodeSlug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnicodeSlug

Permissive slug generator that works with unicode. Port to C#/.NET of https://github.com/jeremys/uslug. Adds support for Korean characters.

Only characters from the Unicode categories Letter, Number and Separator (see Unicode Categories) and the common CJK Unified Ideographs as defined in the version 6.0.0 of the Unicode specification plus the Hangul set.

Quick Examples

using UnicodeSlug;

var slugOptions = new SlugOptions();
slugOptions.GenerateSlug("Быстрее и лучше!"); // "быстрее-и-лучше""
slugOptions.GenerateSlug("汉语/漢語") // "汉语漢語""

var slugOptionsCasing = new SlugOptions 
{
	Lowercase = false
};
var slugOptionsSpaces = new SlugOptions 
{
	Spaces = true
};
var slugOptionsChars = new SlugOptions 
{
	AllowedChars = new [] { '|' }
};
slugOptionsCasing.GenerateSlug("Y U NO") // "Y-U-NO"
slugOptionsSpaces.GenerateSlug("Y U NO") // "y u no"
slugOptionsChars.GenerateSlug("Y-U|NO") // "yu|no"

Installation

From NuGet https://www.nuget.org/packages/unicodeslug

Install-Package UnicodeSlug

Options

  • Public Properties
    • AllowedChars: an array of chars that you want to be whitelisted. Default: '-_~'.
    • Lowercase: a Boolean to force the slug to lowercase. Default: true.
    • Spaces: a Boolean to allow spaces. Default: false.

License

MIT

About

A permissive slug generator that works with Unicode, as a .NET class library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages