22#include <rtl/ustring.hxx>
23#include <rtl/ustrbuf.hxx>
31 return rtl::Uri::encode( rSegment,
32 rtl_UriCharClassPchar,
33 rtl_UriEncodeIgnoreEscapes,
34 RTL_TEXTENCODING_UTF8 );
39 return rtl::Uri::decode( rSegment,
40 rtl_UriDecodeWithCharset,
41 RTL_TEXTENCODING_UTF8 );
50 sal_Int32 nFragment = rURI.lastIndexOf(
u'#' );
51 if ( nFragment != -1 )
52 aFragment = rURI.copy( nFragment + 1 );
54 sal_Int32 nParams = ( nFragment == -1 )
55 ? rURI.lastIndexOf(
u'?' )
56 : rURI.lastIndexOf(
u'?', nFragment );
58 aParams = ( nFragment == -1 )
59 ? rURI.copy( nParams + 1 )
60 : rURI.copy( nParams + 1, nFragment - nParams - 1 );
62 aURI = ( nParams != -1 )
63 ? rURI.copy( 0, nParams )
65 ? rURI.copy( 0, nFragment )
68 if ( aFragment.getLength() > 1 )
70 rtl::Uri::encode( aFragment,
72 rtl_UriEncodeKeepEscapes,
73 RTL_TEXTENCODING_UTF8 );
75 if ( aParams.getLength() > 1 )
77 rtl::Uri::encode( aParams,
79 rtl_UriEncodeKeepEscapes,
80 RTL_TEXTENCODING_UTF8 );
82 OUStringBuffer aResult(256);
87 rtl::Uri::encode( aURI.getToken( 0,
'/',
nIndex ),
88 rtl_UriCharClassPchar,
89 rtl_UriEncodeKeepEscapes,
90 RTL_TEXTENCODING_UTF8 ) );
92 aResult.append(
u'/' );
96 if ( !aParams.isEmpty() )
97 aResult.append(
u"?" + aParams );
99 if ( !aFragment.isEmpty() )
100 aResult.append(
u"#" + aFragment );
102 return aResult.makeStringAndClear();
OUString encodeURI(const OUString &rURI)
OUString decodeSegment(const OUString &rSegment)
OUString encodeSegment(const OUString &rSegment)