+wxString wxURL::ConvertToValidURI(const wxString& uri)
+{
+ wxString out_str;
+ wxString hexa_code;
+ size_t i;
+
+ for (i=0;i<uri.Len();i++) {
+ wxChar c = uri.GetChar(i);
+
+ if (c == _T(' '))
+ out_str += _T('+');
+ else {
+ if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('/')) {
+ hexa_code.Printf(_T("%%%02X"), c);
+ out_str += hexa_code;
+ } else
+ out_str += c;
+ }
+ }
+
+ return out_str;
+}
+
+wxString wxURL::ConvertFromURI(const wxString& uri)
+{
+ int code;
+ int i;
+ wxString new_uri;
+
+ new_uri.Empty();
+
+ i = 0;
+ while (i<uri.Len()) {
+ if (uri[i] == _T('%')) {
+ i++;
+ if (uri[i] >= _T('A') && uri[i] <= _T('F'))
+ code = (uri[i] - _T('A') + 10) * 16;
+ else
+ code = (uri[i] - _T('0')) * 16;
+ i++;
+ if (uri[i] >= _T('A') && uri[i] <= _T('F'))
+ code += (uri[i] - _T('A')) + 10;
+ else
+ code += (uri[i] - _T('0'));
+ i++;
+ new_uri += (wxChar)code;
+ continue;
+ }
+ new_uri += uri[i];
+ i++;
+ }
+ return new_uri;