Model view controller Unicode&;在MVC URI中使用的国际段塞名称?
我正在查看Azure上针对MVC的MSFT,它们的代码与以下类似:Model view controller Unicode&;在MVC URI中使用的国际段塞名称?,model-view-controller,unicode,seo,asp.net-mvc-3,slug,Model View Controller,Unicode,Seo,Asp.net Mvc 3,Slug,我正在查看Azure上针对MVC的MSFT,它们的代码与以下类似: 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.Repl
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);
}
publicstaticstringgenerateslug(此字符串为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你可以看一看。似乎这位评论者对亚洲字符的想法是正确的,不确定是否已经完全成熟了。。。