|
|
@ -165,41 +165,60 @@ KIO_EXPORT TQString KIO::itemsSummaryString(uint items, uint files, uint dirs, K
|
|
|
|
KIO_EXPORT TQString KIO::encodeFileName( const TQString & _str )
|
|
|
|
KIO_EXPORT TQString KIO::encodeFileName( const TQString & _str )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQString str( _str );
|
|
|
|
TQString str( _str );
|
|
|
|
|
|
|
|
bool unicode_supported = (TQString::fromLocal8Bit(TQString(TQChar((uint)0x2215)).local8Bit())[0].unicode() != 0x3f);
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
int i = 0;
|
|
|
|
while ( ( i = str.find( "%", i ) ) != -1 )
|
|
|
|
while ( ( i = str.find( "%", i ) ) != -1 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
str.replace( i, 1, "%%");
|
|
|
|
str.replace( i, 1, "%%");
|
|
|
|
i += 2;
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ( ( i = str.find( "/" ) ) != -1 )
|
|
|
|
while ( ( i = str.find( "/" ) ) != -1 ) {
|
|
|
|
str.replace( i, 1, "%2f");
|
|
|
|
if (unicode_supported) {
|
|
|
|
|
|
|
|
// Use U+2215 (DIVISION SLASH) to represent the forward slash
|
|
|
|
|
|
|
|
// While U+2044 (FRACTION SLASH) is a tempting replacement, it can indicate to
|
|
|
|
|
|
|
|
// rendering engines that a combined fraction character should be displayed
|
|
|
|
|
|
|
|
str.replace( i, 1, TQChar((uint)0x2215));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
// Unicode does not appear to be supported on this system!
|
|
|
|
|
|
|
|
// Fall back to older encoding method...
|
|
|
|
|
|
|
|
str.replace( i, 1, "%2f");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
str.replace( i, 1, TQChar((uint)0x2215));
|
|
|
|
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KIO_EXPORT TQString KIO::decodeFileName( const TQString & _str )
|
|
|
|
KIO_EXPORT TQString KIO::decodeFileName( const TQString & _str )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQString str;
|
|
|
|
TQString str;
|
|
|
|
|
|
|
|
bool unicode_supported = (TQString::fromLocal8Bit(TQString(TQChar((uint)0x2215)).local8Bit())[0].unicode() != 0x3f);
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int i = 0;
|
|
|
|
unsigned int i = 0;
|
|
|
|
for ( ; i < _str.length() ; ++i )
|
|
|
|
for ( ; i < _str.length() ; ++i ) {
|
|
|
|
{
|
|
|
|
if ( _str[i]=='%' ) {
|
|
|
|
if ( _str[i]=='%' )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( _str[i+1]=='%' ) // %% -> %
|
|
|
|
if ( _str[i+1]=='%' ) // %% -> %
|
|
|
|
{
|
|
|
|
{
|
|
|
|
str.append('%');
|
|
|
|
str.append('%');
|
|
|
|
++i;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( _str[i+1]=='2' && (i+2<_str.length()) && _str[i+2].lower()=='f' ) // %2f -> /
|
|
|
|
else if ((!unicode_supported) && ( _str[i+1]=='2' && (i+2<_str.length()) && _str[i+2].lower()=='f' )) // %2f -> /
|
|
|
|
{
|
|
|
|
{
|
|
|
|
str.append('/');
|
|
|
|
str.append('/');
|
|
|
|
i += 2;
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
str.append('%');
|
|
|
|
str.append('%');
|
|
|
|
} else
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ( _str[i] == TQChar((uint)0x2215) ) {
|
|
|
|
|
|
|
|
str.append('/');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
str.append(_str[i]);
|
|
|
|
str.append(_str[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
return str;
|
|
|
|