Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I strongly suspect that the data starts with a <a href="http://en.wikipedia.org/wiki/Byte_order_mark" rel="nofollow">byte order mark</a>, which can't be represented in ASCII.</p> <p>It's not clear why you're doing what you're doing in the first place, particularly around the <code>MemoryStream</code>. Why are you creating a UTF-8 encoded byte array, then decoding that to a string (and we don't know what <code>UTF8ByteArrayToString</code> does), then converting it <em>back</em> to a byte array? Why not just write the byte array straight to the client to start with? If you need the data as a string, I'd use a subclass of <code>StringWriter</code> which advertises that it uses UTF-8 as the encoding. If you <em>don't</em> need it as a string, just stick to the byte array.</p> <p>Note that even aside from this first character, the fact that you've got an XML document encoded in UTF-8 means there may well be other non-ASCII characters in the string. Why are you using ASCII at all here?</p> <p>EDIT: Just to be clear, you're fundamentally applying a lossy transformation, <em>and</em> doing it needlessly. Even if you want a local copy of the data, you should have something like this:</p> <pre><code>// Removed bad try/catch block - don't just catch Exception, and don't // just swallow exceptions MemoryStream memoryStream = new MemoryStream(); XmlSerializer xs = new XmlSerializer(typeof(WorkItem)); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); xs.Serialize(xmlTextWriter, p); // Removed pointless conversion to/from string // Removed pointless BinaryWriter (just use the stream) // An alternative would be memoryStream.WriteTo(clientStream); byte[] data = memoryStream.ToArray(); clientStream.Write(data, 0, data.Length); Console.WriteLine(" send.." + data); // Removed Close calls - you should use "using" statements to dispose of // streams automatically. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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