HttpUtility.ParseQueryString() always encodes special characters to unicode

后端 未结 4 1683
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 14:16

When using HttpUtility from System.Web, I find that everytime I call the method .ParseQueryString I am having special characters encode to their unicode equivalent represent

4条回答
  •  醉酒成梦
    2020-12-16 14:56

    I am not familiar with ParseQueryString, but it appears from the documentation to convert a properly formatted query into name value pairs. From your post it appears you are trying to do the opposite: convert data pairs to a properly formatted query. Instead you may try using HttpUtility.UrlEncode

    string text = "ich möchte diese Bild für andere freigeben"
    var urlBuilder = new UriBuilder(url);
    String query = "text=" + HttpUtility.UrlEncode(text);  
    urlBuilder.Query = query;
    string finalUrl = urlBuilder.ToString();
    

提交回复
热议问题