Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7 Umlauts and Special Characters
    text
    copied!<p>I'm facing an encoding problem in WP7. I make a json request to an API, the response includes German umlauts but for some reason it shows up incorrectly. That's the code for making the request:</p> <pre><code>public static void makeRequest(string requestString,List&lt;String&gt; parameters,Action&lt;string&gt; handleRequestResult) { //generate a random nonce and a timestamp Random rand = new Random(); Random rand2 = new Random(); string nonce1 = rand.Next().ToString(); string nonce2 = rand2.Next().ToString(); string nonce = nonce1 + nonce2; string timestamp = GetTimestamp(); //create the parameter string in alphabetical order //string parameters = "oauth_callback=" + UrlHelper.Encode("http://www.example.com"); parameters.Add("oauth_consumer_key=" + ConsumerKey); parameters.Add("oauth_nonce=" + nonce); parameters.Add("oauth_signature_method=HMAC-SHA1"); parameters.Add("oauth_timestamp=" + timestamp); parameters.Add("oauth_version=1.0"); //sorting the list of parameters (adding '&amp;' between them) string sortedParameters = sortParams(parameters); //generate a signature base on the current requeststring and parameters and adding it to request string string signature = generateSignature("GET", requestString, sortedParameters); string url = requestString + "?" + sortedParameters + "&amp;oauth_signature=" + signature; //test the request WebClient web2 = new WebClient(); web2.Encoding = UTF8Encoding.UTF8; //string result = web.DownloadString(url); web2.DownloadStringCompleted += (sender, e) =&gt; { string result = (string)e.Result; handleRequestResult(result); //App.ViewModel.LoadData(result); }; web2.DownloadStringAsync(new Uri(url)); } </code></pre> <p>And here's an example code for loading the response to the view:</p> <pre><code>public void LoadBlogPosts(string content) { if (!AddToExistingBlogs) { this.BlogPosts.Clear(); } XDocument xml = XDocument.Parse(content); foreach (XElement element in xml.Descendants("item")) { BlogViewModel newBlog = new BlogViewModel(); newBlog.Title = element.Element("title").Value; newBlog.Description = element.Element("description").Value; newBlog.Link = element.Element("link").Value; newBlog.Category = element.Element("category").Value; //newBlog.Comments = element.Element("comments").Value; newBlog.PubDate = element.Element("pubDate").Value; XNamespace dc = "http://purl.org/dc/elements/1.1/"; XNamespace wfw = "http://wellformedweb.org/CommentAPI/"; XNamespace atom = "http://www.w3.org/2005/Atom"; XNamespace sy = "http://purl.org/rss/1.0/modules/syndication/"; XNamespace slash = "http://purl.org/rss/1.0/modules/slash/"; XNamespace contentn = "http://purl.org/rss/1.0/modules/content/"; newBlog.Dccreator = element.Element(dc + "creator").Value; newBlog.Guid = element.Element("guid").Value; newBlog.WfwCommentRss = element.Element(wfw + "commentRss").Value; newBlog.SlashComments = element.Element(slash + "comments").Value; newBlog.Content = "&lt;html&gt;&lt;body style='color: white; background-color:Black'&gt;"; newBlog.Content += element.Element(contentn + "encoded").Value; newBlog.Content += "&lt;/body&gt;&lt;/html&gt;"; // //Extract images from post: // // Size the control to fill the form with a margin var reg = new Regex("src=(?:\"|\')?(?&lt;imgSrc&gt;[^&gt;]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?"); var match = reg.Match(newBlog.Content); if (match.Success) { newBlog.FeaturedImage = match.Groups["imgSrc"].Value; } else { newBlog.FeaturedImage = @"http://karkur.com/no_image.png"; } BlogPosts.Add(newBlog); } } </code></pre> <p>That's the result that I get: <img src="https://i.stack.imgur.com/SE6UH.png" alt="enter image description here"></p> <p>Basically what I need is something to unescape unicode characters in WP7: convert this: <img src="https://i.stack.imgur.com/q4hEk.png" alt="enter image description here"></p> <p>to normal characters</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload