LibreOffice
LibreOffice 24.2 SDK C/C++ API Reference
|
#include "sal/config.h"
#include "rtl/textenc.h"
#include "rtl/ustring.h"
#include "sal/saldllapi.h"
#include "sal/types.h"
Go to the source code of this file.
Enumerations | |
enum | rtl_UriCharClass { rtl_UriCharClassNone, rtl_UriCharClassUric, rtl_UriCharClassUricNoSlash, rtl_UriCharClassRelSegment, rtl_UriCharClassRegName, rtl_UriCharClassUserinfo, rtl_UriCharClassPchar, rtl_UriCharClassUnoParamValue, rtl_UriCharClass_FORCE_EQUAL_SIZE = SAL_MAX_ENUM } |
Various predefined URI 'char classes. More... | |
enum | rtl_UriEncodeMechanism { rtl_UriEncodeIgnoreEscapes, rtl_UriEncodeKeepEscapes, rtl_UriEncodeCheckEscapes, rtl_UriEncodeStrict, rtl_UriEncodeStrictKeepEscapes, rtl_UriEncode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM } |
The mechanism describing how escape sequences in the input of rtl_uriEncode() are handled. More... | |
enum | rtl_UriDecodeMechanism { rtl_UriDecodeNone, rtl_UriDecodeToIuri, rtl_UriDecodeWithCharset, rtl_UriDecodeStrict, rtl_UriDecode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM } |
The mechanism describing how rtl_uriDecode() translates (part of) a URI into a Unicode string. More... | |
Functions | |
SAL_DLLPUBLIC sal_Bool const * | rtl_getUriCharClass (rtl_UriCharClass eCharClass) SAL_THROW_EXTERN_C() |
Map a predefined rtl_UriCharClass to a form usable by rtl_uriEncode(). More... | |
SAL_DLLPUBLIC void | rtl_uriEncode (rtl_uString *pText, sal_Bool const *pCharClass, rtl_UriEncodeMechanism eMechanism, rtl_TextEncoding eCharset, rtl_uString **pResult) SAL_THROW_EXTERN_C() |
Encode a text as (part of) a URI. More... | |
SAL_DLLPUBLIC void | rtl_uriDecode (rtl_uString *pText, rtl_UriDecodeMechanism eMechanism, rtl_TextEncoding eCharset, rtl_uString **pResult) SAL_THROW_EXTERN_C() |
Decode (a part of) a URI. More... | |
SAL_DLLPUBLIC sal_Bool | rtl_uriConvertRelToAbs (rtl_uString *pBaseUriRef, rtl_uString *pRelUriRef, rtl_uString **pResult, rtl_uString **pException) SAL_THROW_EXTERN_C() |
Convert a relative URI reference into an absolute URI. More... | |
enum rtl_UriCharClass |
Various predefined URI 'char classes.
'
A 'char class' defines which (ASCII) characters can be written 'as they are' in a part of a Uri, and which characters have to be written using escape sequences ('' followed by two hex digits). Characters outside the ASCII range are always written using escape sequences.
If there are other frequently used char classes, they can be added to this enumeration; the function rtl_getUriCharClass() has to be adapted then, too.
The mechanism describing how rtl_uriDecode() translates (part of) a URI into a Unicode string.
The mechanism describing how escape sequences in the input of rtl_uriEncode() are handled.
SAL_DLLPUBLIC sal_Bool const* rtl_getUriCharClass | ( | rtl_UriCharClass | eCharClass | ) |
Map a predefined rtl_UriCharClass to a form usable by rtl_uriEncode().
The function rtl_uriEncode() expects an array of 128 booleans, and this function maps rtl_UriCharClass enumeration members to such arrays.
eCharClass | Any valid member of rtl_UriCharClass. |
SAL_DLLPUBLIC sal_Bool rtl_uriConvertRelToAbs | ( | rtl_uString * | pBaseUriRef, |
rtl_uString * | pRelUriRef, | ||
rtl_uString ** | pResult, | ||
rtl_uString ** | pException | ||
) |
Convert a relative URI reference into an absolute URI.
This function uses the strict parser algorithm described in RFC 3986, section 5.2.
This function signals exceptions by returning false and letting pException point to a message explaining the exception.
pBaseUriRef | An absolute URI that serves as the base URI. If it has to be inspected (i.e., pRelUriRef is not an absolute URI already), and it is not an absolute URI (i.e., does not begin with a <scheme ":"> part), an exception will be signaled. |
pRelUriRef | A URI reference that may be either absolute or relative. If it is absolute, it will be returned unmodified. |
pResult | Returns an absolute URI. Must itself not be null, and must point to either null or a valid string. If an exception is signalled, it is left unchanged. |
pException | Returns an explanatory message in case an exception is signalled. Must itself not be null, and must point to either null or a valid string. If no exception is signalled, it is left unchanged. |
SAL_DLLPUBLIC void rtl_uriDecode | ( | rtl_uString * | pText, |
rtl_UriDecodeMechanism | eMechanism, | ||
rtl_TextEncoding | eCharset, | ||
rtl_uString ** | pResult | ||
) |
Decode (a part of) a URI.
pText | Any Unicode string. Must not be null. (If the input is indeed part of a valid URI, this string will only contain a subset of the ASCII characters, but this function also handles other Unicode characters properly.) |
eMechanism | The mechanism describing how the input text is translated into a Unicode string. |
eCharset | When the decode mechanism is rtl_UriDecodeWithCharset, all escape sequences in the input text are interpreted as characters from this charset. Those characters are translated to Unicode characters in the resulting output, if possible. |
When the decode mechanism is rtl_UriDecodeNone or rtl_UriDecodeToIuri, this parameter is ignored (and is best specified as RTL_TEXTENCODING_UTF8).
pResult | Returns a decoded representation of the input text. Must itself not be null, and must point to either null or a valid string. |
If the decode mechanism is rtl_UriDecodeStrict, and pText cannot be converted to eCharset because it contains (encodings of) unmappable characters (which implies that pText is not empty), then an empty string is returned.
SAL_DLLPUBLIC void rtl_uriEncode | ( | rtl_uString * | pText, |
sal_Bool const * | pCharClass, | ||
rtl_UriEncodeMechanism | eMechanism, | ||
rtl_TextEncoding | eCharset, | ||
rtl_uString ** | pResult | ||
) |
Encode a text as (part of) a URI.
pText | Any Unicode string. Must not be null. |
pCharClass | A char class, represented as an array of 128 booleans (true means keep the corresponding ASCII character unencoded, false means encode it). Must not be null, and the boolean corresponding to the percent sign (0x25) must be false. (See rtl_getUriCharClass() for a function mapping from rtl_UriCharClass to such arrays.) |
eMechanism | The mechanism describing how escape sequences in the input text are handled. |
eCharset | When Unicode characters from the input text have to be written using escape sequences (because they are either outside the ASCII range or do not belong to the given char class), they are first translated into this charset before being encoded using escape sequences. |
Also, if the encode mechanism is rtl_UriEncodeCheckEscapes, all escape sequences already present in the input text are interpreted as characters from this charset.
pResult | Returns an encoded representation of the input text. Must itself not be null, and must point to either null or a valid string. |
If the encode mechanism is rtl_UriEncodeStrict, and pText cannot be converted to eCharset because it contains unmappable characters (which implies that pText is not empty), then an empty string is returned.