void DecodedDataDocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)
{
    std::cout<<"DecodedDataDocumentParser::appendBytes!!!!!!!: "<< ( data!=NULL ? strlen(data) : 0) <<std::endl;

    string dataString;

    if (data!=NULL) {

	dataString = data;
        dataString = replaceSocamPersonTags(dataString);
        dataString = replaceSocamAccelerometerTags(dataString);
        //cout<<"Result:"<<replacedData.c_str()<<endl;
	//cout<<endl<<endl<<"REPLACED DATA:"<<data<<endl<<endl;

    }

    if (!length && !shouldFlush)
        return;

    TextResourceDecoder* decoder = writer->createDecoderIfNeeded();
    String decoded = decoder->decode(dataString.c_str(), dataString.size());
    if (shouldFlush)
        decoded += decoder->flush();

    cout<<"Decoded:"<<decoded.ascii().data()<<endl;

    if (decoded.isEmpty())
        return;

    writer->reportDataReceived();

    append(decoded);
}
void DecodedDataDocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)
{
    if (!length && !shouldFlush)
        return;

    TextResourceDecoder* decoder = writer->createDecoderIfNeeded();
    String decoded = decoder->decode(data, length);
    if (shouldFlush)
        decoded += decoder->flush();
    if (decoded.isEmpty())
        return;

    writer->reportDataReceived();

    append(decoded);
}