locked
Issue with displaying Unicode Characters returned by a webservice

    Question

  • Hi, We are developing a mobile application which provides multi language selection (Arabic & English). but we are having an issue with displaying returned JSON which has Arabic text. The output we get is as below. Our .net client throws the following exception. Appreciate your kind help and thank you in advance.

    [net_WebHeaderInvalidControlChars]

    Arguments:

    Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.7.60408.0&File=System.Net.dll&Key=net_WebHeaderInvalidControlChars

    Parameter name: name”

    Returned JSON:

    https://72.44.81.184/~shababcapital/wp-json/posts?type=news&lang=ar

    Connection ? Keep-Alive
    Content-Type ? application/json; charset=UTF-8
    Date ? Fri, 27 Feb 2015 03:35:43 GMT
    Keep-Alive ? timeout=1, max=100
    Last-Modified ? Thu, 26 Feb 2015 14:43:55 GMT
    Link ? <http://72.44.81.184/~shababcapital/wp-json/posts/131>; rel="item"; title="387 Ù?اعب Ù?Ù?اعبة ضÙ?Ù? فعاÙ?Ù?ات اÙ?تدرÙ?ب اÙ?Ù?ستÙ?ر Ù?اÙ?تشاف اÙ?Ù?Ù?اÙ?ب اÙ?رÙ?اضÙ?Ø©", <http://72.44.81.184/~shababcapital/wp-json/posts/119>; rel="item"; title="387 Ù?اعب Ù?Ù?اعبة ضÙ?Ù? فعاÙ?Ù?ات اÙ?تدرÙ?ب اÙ?Ù?ستÙ?ر Ù?اÙ?تشاف اÙ?Ù?Ù?اÙ?ب اÙ?رÙ?اضÙ?Ø©", <http://72.44.81.184/~shababcapital/wp-json/posts/118>; rel="item"; title="اÙ?جÙ?در Ù?ؤÙ?د استÙ?رار "اÙ?شباب Ù?اÙ?رÙ?اضة" فÙ? دعÙ? Ù?سÙ?رة اÙ?Ù?راÙ?ز اÙ?شبابÙ?Ø©", <http://72.44.81.184/~shababcapital/wp-json/posts/117>; rel="item"; title="اÙ?جÙ?در Ù?Ø´Ù?د بدÙ?ر اÙ?Ù?راÙ?ز اÙ?شبابÙ?Ø© فÙ? تطبÙ?Ù? رؤÙ?Ø© Ù?اصر بÙ? Ø­Ù?د فÙ? احتضاÙ? اÙ?شباب", <http://72.44.81.184/~shababcapital/wp-json/posts/55>; rel="item"; title="اÙ?جÙ?در: Ù?دفÙ?ا تحÙ?Ù?Ù? أفضÙ? فرص استثÙ?ارÙ?Ø© Ù?Ù?Ø£Ù?دÙ?Ø© اÙ?Ù?Ø·Ù?Ù?Ø© Ù?Ù?بارÙ? اÙ?Ù?شرÙ?ع اÙ?جدÙ?د", <http://72.44.81.184/~shababcapital/wp-json/posts/45>; rel="item"; title="اÙ?جÙ?در Ù?Ø´Ù?د بدÙ?ر اÙ?Ù?راÙ?ز اÙ?شبابÙ?Ø© فÙ? تطبÙ?Ù? رؤÙ?Ø© Ù?اصر بÙ? Ø­Ù?د فÙ? احتضاÙ? اÙ?شباب"
    Server ? Apache
    Transfer-Encoding ? chunked
    X-Content-Type-Options ? nosniff
    X-Pingback ? http://72.44.81.184/~shababcapital/xmlrpc.php
    X-Powered-By ? PHP/5.4.24
    X-WP-Total ? 6
    X-WP-TotalPages ? 1




    Tuesday, March 3, 2015 5:11 AM

Answers

  • I originally downloaded it using IE and viewed the content in Fiddler.  Use this code to get the content:

    string url = "https://72.44.81.184/~shababcapital/wp-json/posts?type=news&lang=ar";
                
          
    HttpBaseProtocolFilter MyFilter = new HttpBaseProtocolFilter();
    MyFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.InvalidName);
    HttpClient request = new HttpClient(MyFilter);
               
    string response = await request.GetStringAsync(new Uri(url));
    MyContent.Text = response;



    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by JDSantos18 Tuesday, March 10, 2015 5:13 AM
    Monday, March 9, 2015 4:17 PM
    Moderator

All replies

  • Can you provide the code which you are using to display the content? I am able to see the Arabic content just fine here.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, March 3, 2015 3:30 PM
    Moderator
  • Thank you Matt for the reply. appreciate please if you can share or direct us on what method you use for calling the webservice. 

    Below is the code we use for calling the webservice. we receive an error {System.ArgumentException:[net_WebHeaderInvalidControlChars]Arguments:Debugging resour strings are unavailable.

    Thanks.


    protected async override void OnNavigatedTo(NavigationEventArgs e)
    {
        WebClient request = new WebClient();
        request.Encoding = Encoding.GetEncoding("UTF-8");
        request.DownloadStringAsync(new Uri(url));
        request.DownloadStringCompleted += request_DownloadStringCompleted;
    }
    

    • Edited by JDSantos18 Monday, March 9, 2015 4:04 AM
    Sunday, March 8, 2015 5:26 AM
  • I originally downloaded it using IE and viewed the content in Fiddler.  Use this code to get the content:

    string url = "https://72.44.81.184/~shababcapital/wp-json/posts?type=news&lang=ar";
                
          
    HttpBaseProtocolFilter MyFilter = new HttpBaseProtocolFilter();
    MyFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.InvalidName);
    HttpClient request = new HttpClient(MyFilter);
               
    string response = await request.GetStringAsync(new Uri(url));
    MyContent.Text = response;



    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by JDSantos18 Tuesday, March 10, 2015 5:13 AM
    Monday, March 9, 2015 4:17 PM
    Moderator
  • Works Perfect... Thanks you so much for the time and help.
    Tuesday, March 10, 2015 5:13 AM