gpt4 book ai didi

model-view-controller - 在 MVC URI 中使用的 Unicode 和国际 slug 名称?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:47:10 25 4
gpt4 key购买 nike

我正在查看 MSFT Patterns and Practices guide对于 Azure 上的 MVC,它们的代码类似于以下内容:

    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);
}

我必须做出哪些改变才能支持东方语言和非英语语言,同时仍然保持 slug 的 SEO 优势?

最佳答案

关于model-view-controller - 在 MVC URI 中使用的 Unicode 和国际 slug 名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5073874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com