0

I have a webpage that makes an ajax call to a WCF service to return a decrypted log file as a string. The web service simply took a device name, looked up the path, called an external exe to decrypt the file and returned the contents as a string directly. I used the external exe as that exe is responsible for creating and encrypting the log file in the first place. Apparently there was an issue with one of the log files and forced the author to change it to return a UTF-16 string when I call it to decrypt a file. In Chrome the string displays fine but in IE it only displays the 1st character (basically the only non unicode looking character). Here is a sample of what I am getting back from my WCF call:

Any idea what I can do to make this display in IE? Like I said, it displays in Chrome just fine.

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-UA-Compatible: IE=edge
Date: Tue, 03 Dec 2013 19:26:28 GMT

"0\u00005\u0000\/\u00002\u00003\u0000\/\u00002\u00000\u00001\u00003\u0000 \u00000\u00008\u0000:\u00000\u00004\u0000:\u00005\u00007\u0000\u0015\u00001\u0000.\u00000\u0000.\..."

I have the WCF webservice method defined like this:

[WebInvoke(UriTemplate = "GetCriticalErrorLog",
    Method = "POST",
    RequestFormat = WebMessageFormat.Json,
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.WrappedRequest)]
string GetCriticalErrorLog(string unitname, short type);

This is what I get in C# code when I read the file and what the method returns to the browser: "0\05\0/\02\03\0/\02\00\01\03\0 \00\08\0:\00\04\0:\05\07\0\01\0.\00\0.\01\04\02\00\0 \0\0V\0i\0s\0i\0o\0n\0C\0o\0n\0f\0i\0g\0(\01\0.\00\0.\01\01\08\0)\0\0A\0p\0p\0M\0a\0i\0n\0W\0n\0d\0.\0c\0p\0p\0(\02\00\00\03\0)\0\0..."

I just discovered that a few of the log files do display in IE so there must be something in the content that causes the issue that does not cause a problem in Chrome.

mdutra
  • 393
  • 5
  • 18
  • The message headers declare UTF-8, not UTF-16. And the data is in fact JSON encoded in a manner that makes it processable according to any ASCII-compatible encoding, but *not* UTF-16 (which is not ASCII-compatible. So does the sample represent the actual byte data? – Jukka K. Korpela Dec 03 '13 at 20:27
  • I have a WCF service method defined like this: [WebInvoke(UriTemplate = "GetCriticalErrorLog", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] string GetCriticalErrorLog(string unitname, short type); I never specified the encoding so there must be some default conversion occurring there. – mdutra Dec 03 '13 at 20:49
  • possible duplicate of [Displaying UTF-16 characters on web browser](http://stackoverflow.com/questions/13132976/displaying-utf-16-characters-on-web-browser) – Paul Sweatte Oct 07 '14 at 01:28

0 Answers0