本文介绍了与Uri.EscapeUriString()关于重音符号问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我试图把一个URL与重音字符的功能,如Percepção时,输出Percep%C3%A7%C3%A 3 O,而无法正常工作。然而,Percep%E7%e3o做工作的方式是应该的。

If I try to put a URL in the function with accented characters, like "Percepção", it outputs "Percep%C3%A7%C3%A3o", which doesn't work correctly. However, "Percep%e7%e3o" does work the way it should.

String Result = Uri.EscapeUriString("Percepção");

在此先感谢。

Thanks in advance.

推荐答案

我只是第一次编码原始字符串为ASCII字节,然后编码回UTF8修复了这个问题。

I just fixed this issue by encoding the original string to ASCII bytes first, and then encoding it back to UTF8.

String Result = Uri.EscapeUriString(Encoding.UTF8.GetString(Encoding.ASCII.GetBytes("Percepção")));

由于二进制codeR一些更多的细节。

Thanks to binarycoder for some more details.

这篇关于与Uri.EscapeUriString()关于重音符号问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 04:38