0

I'm looking at the MSFT Patterns and Practices guide for MVC on Azure and they have code similar to the following:

    public static string GenerateSlug(this string txt, int maxLength)
    {
        string str = RemoveAccent(txt).ToLower();

        str = Regex.Replace(str, @"[^a-z0-9\s-]", string.Empty);
        str = Regex.Replace(str, @"\s+", " ").Trim();
        str = str.Substring(0, str.Length <= maxLength ? str.Length : maxLength).Trim();
        str = Regex.Replace(str, @"\s", "-");

        return str;
    }

    public static string RemoveAccent(this string txt)
    {
        byte[] bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(txt);
        return System.Text.Encoding.ASCII.GetString(bytes);
    } 

What changes will I have to make to support Eastern and non-english languages, and still keep the SEO benefit of the slug?

halfbit
  • 54,462
  • 46
  • 195
  • 426

1 Answers1

0

You may take a look at how the slugs are generated on StackOverflow.

Community
  • 1
  • 1
Darin Dimitrov
  • 960,118
  • 257
  • 3,196
  • 2,876
  • Seems like this commenter had the right idea with Asian characters, not sure if it's fully baked yet... http://stackoverflow.com/questions/25259/how-do-you-include-a-webpage-title-as-part-of-a-webpage-url/645130#645130 – halfbit Feb 22 '11 at 18:24