tags:

views:

138

answers:

1

We have implmented a REST-style get service Using WCF in .Net 3.5. This service retrieves research documents. The string 'synopsis' indicated in the code bolow contains non-english characteres which the browser deliveres as "????????".

private void ReturnSynopsisInfo(IApiWebOperationContext context, OutgoingWebResponseContext outgoingResp, string synopsis) { SetResponseHeaders(outgoingResp, HttpStatusCode.OK); outgoingResp.ContentType = "text/html; charset=UTF-8"; context.Result = new MemoryStream(Encoding.ASCII.GetBytes(synopsis)); }

Any advise is much appreciated.

Thank You.

+1  A: 

It seems you are declaring the encoding as utf-8 in the content-type header, but actually using ASCII encoding in stream. The ASCII encoder will silently change any non-ascii character into a question mark.

You probably want to use UTF8Encoding rater than ASCIIEncoding.

JacquesB
you are 100% correct. don't know how i missed. thank you very much