Confused about encoding strings for sockets

I’m trying to send XML over a socket, it seems fine but when I receive it I see characters like &quot instead of “”. I know it’s an encoding issue but I don’t know enough about how encoding works to really be able to solve this…

Anyone point me in the right direction please?
Edit: Maybe I just need to figure out how to decode the special characters before reading? I send base64 data in the channel info, would any escaping affect the data there. how can I ensure it’s integrity?


My sending code:

String* strTest = new String(CharPointer_UTF8(m_poBuffer));
p_poConnectedSocket->write(strTest->getCharPointer(), strTest->getNumBytesAsUTF8());

My sent XML

<?xml version="1.0" encoding="UTF-8"?>

<SampleData SyncEvent="2" Author="DJ Peanut Butter" Time="" SampleDataID="8255">
  <Data ID="8255" Name="Empty Sample" BPM="0.0" SampleSize="18432">
    <AudioSampleBuffer channel:0="73728"
                       channel:1="73728"/>
  </Data>
</SampleData>

My receiving code (this is in a loop as the xml file is very large)

String strRead(CharPointer_UTF8(m_poBuffer), iBytesRead);
                poStrDataBuffer->append(strRead, iBytesRead);

Received XML looks like this (I truncated it)

<?xml version="1.0" encoding="UTF-8"?>

<SampleData SyncEvent="2" Author="DJ Peanut Butter" Time="" SampleDataID="20389"
            Data="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#1

Sockets don’t have an issues sending binary data, and I don’t see anywhere in the code you posted that is doing the escaping. I think the issue is somewhere else in your code.