• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kio
 

kio/kio

  • kio
  • kio
kremoteencoding.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include <config.h>
20 
21 #include <kdebug.h>
22 #include <kstringhandler.h>
23 #include "kremoteencoding.h"
24 
25 KRemoteEncoding::KRemoteEncoding(const char *name)
26  : codec(0L), d(0L)
27 {
28  setEncoding(name);
29 }
30 
31 KRemoteEncoding::~KRemoteEncoding()
32 {
33  // delete d; // not necessary yet
34 }
35 
36 TQString KRemoteEncoding::decode(const TQCString& name) const
37 {
38 #ifdef CHECK_UTF8
39  if (codec->mibEnum() == 106 && !KStringHandler::isUtf8(name))
40  return TQString::fromLatin1(name);
41 #endif
42 
43  TQString result = codec->toUnicode(name);
44  if (codec->fromUnicode(result) != name)
45  // fallback in case of decoding failure
46  return TQString::fromLatin1(name);
47 
48  return result;
49 }
50 
51 TQCString KRemoteEncoding::encode(const TQString& name) const
52 {
53  TQCString result = codec->fromUnicode(name);
54  if (codec->toUnicode(result) != name)
55  return name.latin1();
56 
57  return result;
58 }
59 
60 TQCString KRemoteEncoding::encode(const KURL& url) const
61 {
62  return encode(url.path());
63 }
64 
65 TQCString KRemoteEncoding::directory(const KURL& url, bool ignore_trailing_slash) const
66 {
67  TQString dir = url.directory(true, ignore_trailing_slash);
68 
69  return encode(dir);
70 }
71 
72 TQCString KRemoteEncoding::fileName(const KURL& url) const
73 {
74  return encode(url.fileName());
75 }
76 
77 void KRemoteEncoding::setEncoding(const char *name)
78 {
79  // don't delete codecs
80 
81  if (name)
82  codec = TQTextCodec::codecForName(name);
83  else
84  codec = TQTextCodec::codecForMib( 106 ); // fallback to UTF-8
85 
86  if (codec == 0L)
87  codec = TQTextCodec::codecForMib(1);
88 
89  kdDebug() << k_funcinfo << "setting encoding " << codec->name()
90  << " for name=" << name << endl;
91 }
92 
93 void KRemoteEncoding::virtual_hook(int, void*)
94 {
95 }
KRemoteEncoding::~KRemoteEncoding
virtual ~KRemoteEncoding()
Destructor.
Definition: kremoteencoding.cpp:31
KRemoteEncoding::decode
TQString decode(const TQCString &name) const
Converts the given full pathname or filename to Unicode.
Definition: kremoteencoding.cpp:36
KRemoteEncoding::KRemoteEncoding
KRemoteEncoding(const char *name=0L)
Constructor.
Definition: kremoteencoding.cpp:25
KRemoteEncoding::setEncoding
void setEncoding(const char *name)
Sets the encoding being used.
Definition: kremoteencoding.cpp:77
KRemoteEncoding::encode
TQCString encode(const TQString &name) const
Converts the given name from Unicode.
Definition: kremoteencoding.cpp:51
KRemoteEncoding::fileName
TQCString fileName(const KURL &url) const
Converts the given URL into 8-bit form and retrieve the filename.
Definition: kremoteencoding.cpp:72
KRemoteEncoding::directory
TQCString directory(const KURL &url, bool ignore_trailing_slash=true) const
Converts the given URL into 8-bit form and separate the dirname from the filename.
Definition: kremoteencoding.cpp:65

kio/kio

Skip menu "kio/kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kio/kio

Skip menu "kio/kio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kio by doxygen 1.8.13
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |