Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PString PURL::UntranslateString ( const PString str,
TranslationType  type 
) [static]

Untranslate a string from a form that was included into a URL into a normal string. All reserved characters for the particular field type are unescaped.

Returns:
String from the URL untranslated.
Parameters:
str  String to be translated.
type  Type of translation.

Definition at line 607 of file http.cxx.

References PString::Delete(), PString::Find(), PString::MakeUnique(), and QueryTranslation.

Referenced by SetPathStr().

{
  PString xlat = str;
  xlat.MakeUnique();

  PINDEX pos;
  if (type == PURL::QueryTranslation) {
    pos = (PINDEX)-1;
    while ((pos = xlat.Find('+', pos+1)) != P_MAX_INDEX)
      xlat[pos] = ' ';
  }

  pos = (PINDEX)-1;
  while ((pos = xlat.Find('%', pos+1)) != P_MAX_INDEX) {
    int digit1 = xlat[pos+1];
    int digit2 = xlat[pos+2];
    if (isxdigit(digit1) && isxdigit(digit2)) {
      xlat[pos] = (char)(
            (isdigit(digit2) ? (digit2-'0') : (toupper(digit2)-'A'+10)) +
           ((isdigit(digit1) ? (digit1-'0') : (toupper(digit1)-'A'+10)) << 4));
      xlat.Delete(pos+1, 2);
    }
  }

  return xlat;
}


Generated by  Doxygen 1.6.0   Back to index