Cross-Platform C++

ot::net
class URLDecoder

#include "ot/net/URLDecoder.h"

A class module containing static methods for decoding strings that have been transmitted as an escaped URL.




Method Summary
static String Decode(const String& s)
         Converts an escaped string in the MIME x-www-form-urlencoded format into a plain Unicode string.
static ByteString DecodeBytes(const ByteString& in)
         Translates a sequence of Bytes which contain HH sequences into a plain sequence of bytes.
static String RawDecode(const String& s)
         Converts a raw-encoded URI string into a Unicode String.

Method Detail

Decode

static String Decode(const String& s)
Converts an escaped string in the MIME x-www-form-urlencoded format into a plain Unicode string. This function reverses the encoding process performed by the URLEncoder::Encode() function. In other words, this function first translates the HH encoded bytes into the corresponding byte values and then transforms the resulting byte sequence into Unicode characters.

For consistency with convention and the URLEncoder::Encode() method, the byte sequence resulting from the HH decoding stage is assumed to be UTF-8. If and invalid UTF-8 sequence is detected then an IllegalCharacterException wil be thrown. If applications need to cope with HH-escaped URLs which have not been converted to UTF-8, the DecodeBytes() function should be used.

Exceptions:
IllegalCharacterException - if the encoded uri contains an invalid UTF-8 sequence. This exception may also be thrown if the UTF-8 sequence contains an encoded character which cannot be represented in the native OpenTop encoding.
See also:
URLEncoder::Encode()

DecodeBytes

static ByteString DecodeBytes(const ByteString& in)
Translates a sequence of Bytes which contain HH sequences into a plain sequence of bytes. This transformation is usually an interim step in the decoding of a URI, where the final step involves interpreting the results as a UTF-8 encoded character string. However, not all protocols mandate the use of UTF-8 encoding, so this function may be useful when the application has knowledge of how to interpret the HH decoded bytes.

Each byte in the passed sequence is examined and added to the returned ByteString, except for:-

The length of the returned sequence is guaranteed to be no greater than the length of the input sequence.

Returns:
A ByteString containing the decoded bytes.
Since:
OpenTop 1.5

RawDecode

static String RawDecode(const String& s)
Converts a raw-encoded URI string into a Unicode String. This method performs a similar function to Decode(), but the algorithm has been modified to complement the URLEncoder::RawEncode() function which performs an idempotent transformation.

The algorithm employed is described in the W3C XML recommendation section 4.2.2, External Entities.



Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2005 ElCel Technology   Trademark Acknowledgements