0

I'm developing a RESTfull web services using WCF. In this service I'm returning a XML in Stream format which contains '£'. I get this in symbol in XML but on client side I get the '?' instead of '£'.

public Stream HandleMessageStream()
        {
            StreamReader reader = new StreamReader(request);
            string text = "<price>£ 10.00</price>";
            UTF8Encoding encoding = new UTF8Encoding();
            MemoryStream ms = new MemoryStream(encoding.GetBytes(text));
            WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
            return ms;
        }

I tried with different encoding but didn't find the answer. Can anyone help me?

Bhushan
  • 316
  • 1
  • 7
  • 15
  • You could try to encode the pound sign as £ or £ . – Rutix May 16 '13 at 06:45
  • Try to set `text/html; charset="utf-8"` to *ContentType* – I4V May 16 '13 at 06:46
  • How is the client reading the data? If it doesn't know it's UTF-8 then that is the source of your problem. I4V's suggestion may fix the problem, if the client interprets the content type properly. – Steve May 16 '13 at 06:50
  • None of the above suggestions are working – Bhushan May 16 '13 at 06:53
  • I'm using 'Send HTTP Tool' to call the method of the service. In that I'm checking the output returned. – Bhushan May 16 '13 at 06:57

1 Answers1

0

have you tried using

Server.HtmlEncode ?

string text = Server.HtmlEncode("<price>£ 10.00</price>");
Carlos Landeras
  • 11,025
  • 11
  • 56
  • 82