使字符串成为URL友好(例如:将蒙特利尔转换为蒙特利尔) [英] Making strings URL Friendly (eg: convert Montréal to Montreal)
问题描述
我正在编写一个需要友好URL的Web应用程序,但是我不确定如何处理非7位ASCII字符.我也不想用URL编码的实体替换带重音符号的字符.是否有C#方法可以进行这种转换,或者我是否需要实际映射出我想处理的每种情况?
I am writing a web application that requires friendly urls, but I'm not sure how to deal with non 7bit ASCII characters. I don't want to replace accented characters with URL encoded entities either. Is there a C# method that allows this sort of conversion or do I need to actually map out every single case I want to handle?
推荐答案
我不知道如何在C#中做到这一点,但是您想要的魔术词是"Unicode分解".有一种标准的方法可以分解诸如é"之类的组合字符,然后您应该能够过滤掉非ASCII字符.
I don't know how to do it in C#, but the magic words you want are "Unicode decomposition". There's a standard way to break down composed characters like "é", and then you should be able to just filter out the non-ASCII ones.
这可能就是您所需要的寻找.
this might be what you're looking for.
这篇关于使字符串成为URL友好(例如:将蒙特利尔转换为蒙特利尔)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!