我有一个包含ASCII字符的字符串,例如
"Tu%C4%9F%C3%A7e%20Kandemir%20-%20G%C3%BCl%C3%BC%20Soldurmam.mp3"
正确的文件名是
"Tuğçe Kandemir - Gülü Soldurmam"
如何转换?
该字符串看起来像是为URL编码的。
您可以使用UrlDecode
从System.Web.HttpUtility
:
var encoded = "Tu%C4%9F%C3%A7e%20Kandemir%20-%20G%C3%BCl%C3%BC%20Soldurmam.mp3";
var decoded = HttpUtility.UrlDecode(encoded);
或者,如果您不使用Web应用程序,则可以使用System.Net.WebUtility.UrlDecode
:
var decoded = WebUtility.UrlDecode(encoded);
这两个都输出以下字符串:
"Tuğçe Kandemir - Gülü Soldurmam.mp3"