I’m trying to send XML over a socket, it seems fine but when I receive it I see characters like " 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="<?xml version="1.0" encoding="UTF-8"?>