Ejemplo n.º 1
0
// Decode an encoded URL string.
wxString URLDecode(const wxString &value) {
	wxString szDecoded;
	wxString szEncoded = value;

	unsigned int nEncodedPos = 0;

	// Replace + with space
	szEncoded.Replace(wxT("+"), wxT(" "));

	// Replace hex encoded characters
	while( nEncodedPos < szEncoded.length() ) {
		wxChar nextChar = szEncoded.GetChar(nEncodedPos);
		nEncodedPos++;

		if(nextChar != wxT('%')) szDecoded.Append( nextChar );
		else
		{
			if( isxdigit(szEncoded.GetChar(nEncodedPos)) && isxdigit(szEncoded.GetChar(nEncodedPos+1)) ) {
				
				int n1 = HexToNumber(szEncoded.GetChar(nEncodedPos));
				int n2 = HexToNumber(szEncoded.GetChar(nEncodedPos+1));

				szDecoded.Append( (wxChar) ((n1 << 4) | n2) );
				nEncodedPos += 2;
			}
		}
	}

	return szDecoded;
}
Ejemplo n.º 2
0
int HtmlDialog::ParseHex(const wxString& hexStr) { // static
	wxASSERT(hexStr.size() == 2);

	const int n1 = HexToNumber(hexStr[0]);
	const int n2 = HexToNumber(hexStr[1]);

	return ((n1 << 4) | n2);
}