Remove wxWebResponse::AsString() conversion parameter
It doesn't make much sense to specify the conversion here, it would ideally be taken from the response Content-Type header itself and currently is just assumed to be UTF-8 anyhow. Also implement fallback to Latin-1 to avoid losing the data entirely if it's not in UTF-8.
This commit is contained in:
@@ -345,16 +345,13 @@ wxString wxWebResponse::GetSuggestedFileName() const
|
||||
return suggestedFilename;
|
||||
}
|
||||
|
||||
wxString wxWebResponse::AsString(wxMBConv * conv) const
|
||||
wxString wxWebResponse::AsString() const
|
||||
{
|
||||
// TODO: try to determine encoding type from content-type header
|
||||
if ( !conv )
|
||||
conv = &wxConvUTF8;
|
||||
|
||||
if ( m_request.GetStorage() == wxWebRequest::Storage_Memory )
|
||||
{
|
||||
// TODO: try to determine encoding type from content-type header
|
||||
size_t outLen = 0;
|
||||
return conv->cMB2WC((const char*)m_readBuffer.GetData(), m_readBuffer.GetDataLen(), &outLen);
|
||||
return wxConvWhateverWorks.cMB2WC((const char*)m_readBuffer.GetData(), m_readBuffer.GetDataLen(), &outLen);
|
||||
}
|
||||
else
|
||||
return wxString();
|
||||
|
Reference in New Issue
Block a user