From 8650108199bf799f21e29811cddaefd579c98c88 Mon Sep 17 00:00:00 2001
From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= <vslavik@fastmail.fm>
Date: Sun, 10 Jun 2007 17:42:41 +0000
Subject: [PATCH] don't use implicit wxString->char*/wchar_t* conversion, it
 will not be available in wxUSE_STL build in the future

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/fltfactory.tex                  |  4 +-
 docs/latex/wx/function.tex                    |  4 +-
 include/wx/archive.h                          |  2 +-
 include/wx/arrstr.h                           |  6 +-
 include/wx/cmdline.h                          |  4 +-
 include/wx/confbase.h                         |  2 +-
 include/wx/ipcbase.h                          |  5 +-
 include/wx/sckipc.h                           |  4 +-
 include/wx/sstream.h                          |  3 +-
 include/wx/strconv.h                          | 10 ++-
 include/wx/stream.h                           |  6 +-
 src/common/arcfind.cpp                        |  2 +-
 src/common/arrstr.cpp                         |  8 +-
 src/common/cmdline.cpp                        | 89 +++++++++++--------
 src/common/config.cpp                         | 33 +++----
 src/common/dcbase.cpp                         | 13 ++-
 src/common/docview.cpp                        |  5 +-
 src/common/dynarray.cpp                       | 51 ++++++-----
 src/common/fileconf.cpp                       | 52 +++++------
 src/common/filename.cpp                       |  2 +-
 src/common/filtfind.cpp                       |  2 +-
 src/common/ftp.cpp                            | 16 ++--
 src/common/http.cpp                           | 10 +--
 src/common/image.cpp                          |  2 +-
 src/common/sstream.cpp                        | 19 ++--
 src/common/strconv.cpp                        | 79 ++++++++--------
 src/common/stream.cpp                         | 14 ++-
 src/common/tarstrm.cpp                        |  4 +-
 src/common/txtstrm.cpp                        |  3 +-
 src/common/uri.cpp                            |  9 +-
 src/common/zipstrm.cpp                        |  8 +-
 src/gtk/animate.cpp                           |  3 +-
 src/gtk/dirdlg.cpp                            |  7 +-
 src/gtk/filedlg.cpp                           | 12 +--
 src/gtk/hyperlink.cpp                         |  2 +-
 src/gtk/menu.cpp                              |  9 +-
 src/gtk/radiobox.cpp                          |  3 +-
 src/msw/utils.cpp                             |  4 +-
 src/richtext/richtexthtml.cpp                 |  4 +-
 src/richtext/richtextstyledlg.cpp             |  2 +-
 src/richtext/richtextxml.cpp                  |  2 +-
 src/unix/dir.cpp                              |  2 +-
 src/unix/mimetype.cpp                         | 12 +--
 src/unix/utilsunx.cpp                         |  5 +-
 src/xml/xml.cpp                               |  3 +-
 tests/arrays/arrays.cpp                       |  2 +-
 tests/datetime/datetimetest.cpp               |  2 +-
 tests/formatconverter/formatconvertertest.cpp |  2 +-
 tests/lists/lists.cpp                         |  2 +-
 tests/mbconv/mbconvtest.cpp                   | 78 ++++++++--------
 tests/regex/regextest.cpp                     |  5 +-
 51 files changed, 329 insertions(+), 303 deletions(-)

diff --git a/docs/latex/wx/fltfactory.tex b/docs/latex/wx/fltfactory.tex
index fdbc719651..1c01f8fac9 100644
--- a/docs/latex/wx/fltfactory.tex
+++ b/docs/latex/wx/fltfactory.tex
@@ -55,7 +55,7 @@ enum wxStreamProtocolType
 
 \membersection{wxFilterClassFactory::CanHandle}\label{wxfilterclassfactorycanhandle}
 
-\constfunc{bool}{CanHandle}{\param{const wxChar* }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
+\constfunc{bool}{CanHandle}{\param{const wxString\& }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
 
 Returns true if this factory can handle the given protocol, MIME type, HTTP
 encoding or file extension.
@@ -66,7 +66,7 @@ can be a complete filename rather than just an extension.
 
 \membersection{wxFilterClassFactory::Find}\label{wxfilterclassfactoryfind}
 
-\func{static const wxFilterClassFactory*}{Find}{\param{const wxChar* }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
+\func{static const wxFilterClassFactory*}{Find}{\param{const wxString\& }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
 
 A static member that finds a factory that can handle a given protocol, MIME
 type, HTTP encoding or file extension.  Returns a pointer to the class
diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex
index c1056d214f..e71c46f651 100644
--- a/docs/latex/wx/function.tex
+++ b/docs/latex/wx/function.tex
@@ -1044,7 +1044,7 @@ temporary storage that should not be deallocated.
 
 \membersection{::wxFindFirstFile}\label{wxfindfirstfile}
 
-\func{wxString}{wxFindFirstFile}{\param{const char *}{spec}, \param{int}{ flags = 0}}
+\func{wxString}{wxFindFirstFile}{\param{const wxString\& }{spec}, \param{int}{ flags = 0}}
 
 This function does directory searching; returns the first file
 that matches the path {\it spec}, or the empty string. Use \helpref{wxFindNextFile}{wxfindnextfile} to
@@ -1342,7 +1342,7 @@ Note that empty tokens will be generated if there are two or more adjacent separ
 
 \membersection{::wxSplitPath}\label{wxsplitfunction}
 
-\func{void}{wxSplitPath}{\param{const char *}{ fullname}, \param{wxString *}{ path}, \param{wxString *}{ name}, \param{wxString *}{ ext}}
+\func{void}{wxSplitPath}{\param{const wxString\&}{ fullname}, \param{wxString *}{ path}, \param{wxString *}{ name}, \param{wxString *}{ ext}}
 
 {\bf NB:} This function is obsolete, please use
 \helpref{wxFileName::SplitPath}{wxfilenamesplitpath} instead.
diff --git a/include/wx/archive.h b/include/wx/archive.h
index f814b8f3b8..67419a91fc 100644
--- a/include/wx/archive.h
+++ b/include/wx/archive.h
@@ -347,7 +347,7 @@ public:
     wxMBConv& GetConv() const
         { if (m_pConv) return *m_pConv; else return wxConvLocal; }
 
-    static const wxArchiveClassFactory *Find(const wxChar *protocol,
+    static const wxArchiveClassFactory *Find(const wxString& protocol,
                                              wxStreamProtocolType type
                                              = wxSTREAM_PROTOCOL);
 
diff --git a/include/wx/arrstr.h b/include/wx/arrstr.h
index 4ce526be62..d1e893cd3d 100644
--- a/include/wx/arrstr.h
+++ b/include/wx/arrstr.h
@@ -45,7 +45,7 @@ public:
     wxArrayString(size_t sz, const wxChar** a);
     wxArrayString(size_t sz, const wxString* a);
 
-    int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const;
+    int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
 
     void Sort(bool reverseOrder = false);
     void Sort(CompareFunction function);
@@ -75,7 +75,7 @@ public:
             Add(src[n]);
     }
 
-    int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const;
+    int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
 };
 
 #else // if !wxUSE_STL
@@ -158,7 +158,7 @@ public:
     // bFromEnd is false or from end otherwise. If bCase, comparison is case
     // sensitive (default). Returns index of the first item matched or
     // wxNOT_FOUND
-  int  Index (const wxChar *sz, bool bCase = true, bool bFromEnd = false) const;
+  int  Index (const wxString& str, bool bCase = true, bool bFromEnd = false) const;
     // add new element at the end (if the array is not sorted), return its
     // index
   size_t Add(const wxString& str, size_t nInsert = 1);
diff --git a/include/wx/cmdline.h b/include/wx/cmdline.h
index dc1d4ee9da..07c893eb75 100644
--- a/include/wx/cmdline.h
+++ b/include/wx/cmdline.h
@@ -209,7 +209,7 @@ public:
     void Reset();
 
     // break down the command line in arguments
-    static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
+    static wxArrayString ConvertStringToArgs(const wxString& cmdline);
 
 private:
     // get usage string
@@ -230,7 +230,7 @@ private:
 class WXDLLIMPEXP_BASE wxCmdLineParser
 {
 public:
-    static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
+    static wxArrayString ConvertStringToArgs(const wxString& cmdline);
 };
 
 #endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
diff --git a/include/wx/confbase.h b/include/wx/confbase.h
index bccafa801e..25f6797049 100644
--- a/include/wx/confbase.h
+++ b/include/wx/confbase.h
@@ -358,7 +358,7 @@ WXDLLIMPEXP_BASE wxString wxExpandEnvVars(const wxString &sz);
 /*
   Split path into parts removing '..' in progress
  */
-WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxChar *sz);
+WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxString& path);
 
 #endif // _WX_CONFBASE_H_
 
diff --git a/include/wx/ipcbase.h b/include/wx/ipcbase.h
index d5c41a52b8..523f1d8e37 100644
--- a/include/wx/ipcbase.h
+++ b/include/wx/ipcbase.h
@@ -56,7 +56,10 @@ public:
 
   // Calls that CLIENT can make
   virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0;
-  virtual bool Execute(const wxString& str) { return Execute(str, -1, wxIPC_TEXT); }
+  // FIXME-UTF8: review this code for compatibility implications, update
+  //             accordingly, don' use c_str() below
+  virtual bool Execute(const wxString& str)
+    { return Execute(str.c_str(), -1, wxIPC_TEXT); }
   virtual wxChar *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0;
   virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
   virtual bool StartAdvise(const wxString& item) = 0;
diff --git a/include/wx/sckipc.h b/include/wx/sckipc.h
index 70ea564b78..6611cc8593 100644
--- a/include/wx/sckipc.h
+++ b/include/wx/sckipc.h
@@ -82,8 +82,10 @@ public:
   void Compress(bool on);
 
   // unhide the Execute overload from wxConnectionBase
+  // FIXME-UTF8: change Execute() to DoExecute() to avoid having to do this;
+  //             don't use c_str() below after removing ANSI build
   virtual bool Execute(const wxString& str)
-    { return Execute(str, -1, wxIPC_TEXT); }
+    { return Execute(str.c_str(), -1, wxIPC_TEXT); }
 
 protected:
   wxSocketBase       *m_sock;
diff --git a/include/wx/sstream.h b/include/wx/sstream.h
index f8e75790ab..1b2cbd0897 100644
--- a/include/wx/sstream.h
+++ b/include/wx/sstream.h
@@ -26,7 +26,6 @@ public:
     // ctor associates the stream with the given string which makes a copy of
     // it
     wxStringInputStream(const wxString& s);
-    virtual ~wxStringInputStream();
 
     virtual wxFileOffset GetLength() const;
 
@@ -40,7 +39,7 @@ private:
     wxString m_str;
 
     // the buffer we're reading from
-    char* m_buf;
+    wxCharBuffer m_buf;
 
     // length of the buffer we're reading from
     size_t m_len;
diff --git a/include/wx/strconv.h b/include/wx/strconv.h
index 1c9cc8d895..b36ad0b862 100644
--- a/include/wx/strconv.h
+++ b/include/wx/strconv.h
@@ -29,6 +29,8 @@
 
 #if wxUSE_WCHAR_T
 
+class WXDLLIMPEXP_BASE wxString;
+
 // the error value returned by wxMBConv methods
 #define wxCONV_FAILED ((size_t)-1)
 
@@ -199,7 +201,7 @@ public:
 class WXDLLIMPEXP_BASE wxConvBrokenFileNames : public wxMBConv
 {
 public:
-    wxConvBrokenFileNames(const wxChar *charset);
+    wxConvBrokenFileNames(const wxString& charset);
     wxConvBrokenFileNames(const wxConvBrokenFileNames& conv)
         : wxMBConv(),
           m_conv(conv.m_conv ? conv.m_conv->Clone() : NULL)
@@ -387,7 +389,7 @@ class WXDLLIMPEXP_BASE wxCSConv : public wxMBConv
 public:
     // we can be created either from charset name or from an encoding constant
     // but we can't have both at once
-    wxCSConv(const wxChar *charset);
+    wxCSConv(const wxString& charset);
     wxCSConv(wxFontEncoding encoding);
 
     wxCSConv(const wxCSConv& conv);
@@ -426,12 +428,12 @@ private:
 
     // set the name (may be only called when m_name == NULL), makes copy of
     // charset string
-    void SetName(const wxChar *charset);
+    void SetName(const char *charset);
 
 
     // note that we can't use wxString here because of compilation
     // dependencies: we're included from wx/string.h
-    wxChar *m_name;
+    char *m_name;
     wxFontEncoding m_encoding;
 
     // use CreateConvIfNeeded() before accessing m_convReal!
diff --git a/include/wx/stream.h b/include/wx/stream.h
index 5ef6ccdc4b..ebdda32f34 100644
--- a/include/wx/stream.h
+++ b/include/wx/stream.h
@@ -354,12 +354,12 @@ public:
     virtual const wxChar * const *GetProtocols(wxStreamProtocolType type
                                                = wxSTREAM_PROTOCOL) const = 0;
 
-    bool CanHandle(const wxChar *protocol,
+    bool CanHandle(const wxString& protocol,
                    wxStreamProtocolType type
                    = wxSTREAM_PROTOCOL) const;
 
 protected:
-    wxString::size_type FindExtension(const wxChar *location) const;
+    wxString::size_type FindExtension(const wxString& location) const;
 
     DECLARE_ABSTRACT_CLASS(wxFilterClassFactoryBase)
 };
@@ -374,7 +374,7 @@ public:
     virtual wxFilterInputStream  *NewStream(wxInputStream *stream)  const = 0;
     virtual wxFilterOutputStream *NewStream(wxOutputStream *stream) const = 0;
 
-    static const wxFilterClassFactory *Find(const wxChar *protocol,
+    static const wxFilterClassFactory *Find(const wxString& protocol,
                                             wxStreamProtocolType type
                                             = wxSTREAM_PROTOCOL);
 
diff --git a/src/common/arcfind.cpp b/src/common/arcfind.cpp
index b71aeb8f9c..cf7cc29c94 100644
--- a/src/common/arcfind.cpp
+++ b/src/common/arcfind.cpp
@@ -23,7 +23,7 @@
 // the archive classes they use.
 
 const wxArchiveClassFactory *
-wxArchiveClassFactory::Find(const wxChar *protocol, wxStreamProtocolType type)
+wxArchiveClassFactory::Find(const wxString& protocol, wxStreamProtocolType type)
 {
     for (const wxArchiveClassFactory *f = GetFirst(); f; f = f->GetNext())
         if (f->CanHandle(protocol, type))
diff --git a/src/common/arrstr.cpp b/src/common/arrstr.cpp
index ace83a6712..ec41806616 100644
--- a/src/common/arrstr.cpp
+++ b/src/common/arrstr.cpp
@@ -197,7 +197,7 @@ void wxArrayString::Shrink()
 }
 
 // searches the array for an item (forward or backwards)
-int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
+int wxArrayString::Index(const wxString& str, bool bCase, bool bFromEnd) const
 {
   if ( m_autoSort ) {
     // use binary search in the sorted array
@@ -211,7 +211,7 @@ int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
     while ( lo < hi ) {
       i = (lo + hi)/2;
 
-      res = wxStrcmp(sz, m_pItems[i]);
+      res = str.compare(m_pItems[i]);
       if ( res < 0 )
         hi = i;
       else if ( res > 0 )
@@ -228,7 +228,7 @@ int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
       if ( m_nCount > 0 ) {
         size_t ui = m_nCount;
         do {
-          if ( m_pItems[--ui].IsSameAs(sz, bCase) )
+          if ( m_pItems[--ui].IsSameAs(str, bCase) )
             return ui;
         }
         while ( ui != 0 );
@@ -236,7 +236,7 @@ int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
     }
     else {
       for( size_t ui = 0; ui < m_nCount; ui++ ) {
-        if( m_pItems[ui].IsSameAs(sz, bCase) )
+        if( m_pItems[ui].IsSameAs(str, bCase) )
           return ui;
       }
     }
diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp
index 30bf7f09d6..88d22ca184 100644
--- a/src/common/cmdline.cpp
+++ b/src/common/cmdline.cpp
@@ -49,11 +49,15 @@
 
 static wxString GetTypeName(wxCmdLineParamType type);
 
-static wxString GetOptionName(const wxChar *p, const wxChar *allowedChars);
+static wxString GetOptionName(wxString::const_iterator p,
+                              wxString::const_iterator end,
+                              const wxChar *allowedChars);
 
-static wxString GetShortOptionName(const wxChar *p);
+static wxString GetShortOptionName(wxString::const_iterator p,
+                                   wxString::const_iterator end);
 
-static wxString GetLongOptionName(const wxChar *p);
+static wxString GetLongOptionName(wxString::const_iterator p,
+                                  wxString::const_iterator end);
 
 // ----------------------------------------------------------------------------
 // private structs
@@ -73,16 +77,16 @@ struct wxCmdLineOption
                       _T("option should have at least one name") );
 
         wxASSERT_MSG
-            (
-                GetShortOptionName(shrt).Len() == shrt.Len(),
-                wxT("Short option contains invalid characters")
-            );
+        (
+            GetShortOptionName(shrt.begin(), shrt.end()).Len() == shrt.Len(),
+            wxT("Short option contains invalid characters")
+        );
 
         wxASSERT_MSG
-            (
-                GetLongOptionName(lng).Len() == lng.Len(),
-                wxT("Long option contains invalid characters")
-            );
+        (
+            GetLongOptionName(lng.begin(), lng.end()).Len() == lng.Len(),
+            wxT("Long option contains invalid characters")
+        );
 
 
         kind = k;
@@ -572,24 +576,25 @@ int wxCmdLineParser::Parse(bool showUsage)
 
         // empty argument or just '-' is not an option but a parameter
         if ( maybeOption && arg.length() > 1 &&
-                wxStrchr(m_data->m_switchChars, arg[0u]) )
+                // FIXME-UTF8: use wc_str() after removing ANSI build
+                wxStrchr(m_data->m_switchChars.c_str(), arg[0u]) )
         {
             bool isLong;
             wxString name;
             int optInd = wxNOT_FOUND;   // init to suppress warnings
 
             // an option or a switch: find whether it's a long or a short one
-            if ( arg[0u] == _T('-') && arg[1u] == _T('-') )
+            if ( arg.length() >= 3 && arg[0u] == _T('-') && arg[1u] == _T('-') )
             {
                 // a long one
                 isLong = true;
 
                 // Skip leading "--"
-                const wxChar *p = arg.c_str() + 2;
+                wxString::const_iterator p = arg.begin() + 2;
 
                 bool longOptionsEnabled = AreLongOptionsEnabled();
 
-                name = GetLongOptionName(p);
+                name = GetLongOptionName(p, arg.end());
 
                 if (longOptionsEnabled)
                 {
@@ -617,9 +622,9 @@ int wxCmdLineParser::Parse(bool showUsage)
 
                 // a short one: as they can be cumulated, we try to find the
                 // longest substring which is a valid option
-                const wxChar *p = arg.c_str() + 1;
+                wxString::const_iterator p = arg.begin() + 1;
 
-                name = GetShortOptionName(p);
+                name = GetShortOptionName(p, arg.end());
 
                 size_t len = name.length();
                 do
@@ -679,15 +684,17 @@ int wxCmdLineParser::Parse(bool showUsage)
             // look at what follows:
 
             // +1 for leading '-'
-            const wxChar *p = arg.c_str() + 1 + name.length();
+            wxString::const_iterator p = arg.begin() + 1 + name.length();
+            wxString::const_iterator end = arg.end();
+
             if ( isLong )
-                p++;    // for another leading '-'
+                ++p;    // for another leading '-'
 
             wxCmdLineOption& opt = m_data->m_options[(size_t)optInd];
             if ( opt.kind == wxCMD_LINE_SWITCH )
             {
                 // we must check that there is no value following the switch
-                if ( *p != _T('\0') )
+                if ( p != arg.end() )
                 {
                     errorMsg << wxString::Format(_("Unexpected characters following option '%s'."), name.c_str())
                              << _T('\n');
@@ -722,12 +729,12 @@ int wxCmdLineParser::Parse(bool showUsage)
                 }
                 else // short option
                 {
-                    switch ( *p )
+                    switch ( (*p).GetValue() )
                     {
                         case _T('='):
                         case _T(':'):
                             // the value follows
-                            p++;
+                            ++p;
                             break;
 
                         case 0:
@@ -744,7 +751,8 @@ int wxCmdLineParser::Parse(bool showUsage)
                             else
                             {
                                 // ... take it from there
-                                p = m_data->m_arguments[n].c_str();
+                                p = m_data->m_arguments[n].begin();
+                                end = m_data->m_arguments[n].end();
                             }
                             break;
 
@@ -764,7 +772,7 @@ int wxCmdLineParser::Parse(bool showUsage)
 
                 if ( ok )
                 {
-                    wxString value = p;
+                    wxString value(p, end);
                     switch ( opt.type )
                     {
                         default:
@@ -797,7 +805,8 @@ int wxCmdLineParser::Parse(bool showUsage)
                         case wxCMD_LINE_VAL_DATE:
                             {
                                 wxDateTime dt;
-                                const wxChar *res = dt.ParseDate(value);
+                                // FIXME-UTF8: ParseDate API will need changes
+                                const wxChar *res = dt.ParseDate(value.c_str());
                                 if ( !res || *res )
                                 {
                                     errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."),
@@ -1140,12 +1149,13 @@ the parameter allowedChars.
 For example, if p points to "abcde-@-_", and allowedChars is "-_",
 this function returns "abcde-".
 */
-static wxString GetOptionName(const wxChar *p,
-    const wxChar *allowedChars)
+static wxString GetOptionName(wxString::const_iterator p,
+                              wxString::const_iterator end,
+                              const wxChar *allowedChars)
 {
     wxString argName;
 
-    while ( *p && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) )
+    while ( p != end && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) )
     {
         argName += *p++;
     }
@@ -1163,14 +1173,16 @@ static wxString GetOptionName(const wxChar *p,
 #define wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION \
     wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION wxT("-")
 
-static wxString GetShortOptionName(const wxChar *p)
+static wxString GetShortOptionName(wxString::const_iterator p,
+                                  wxString::const_iterator end)
 {
-    return GetOptionName(p, wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION);
+    return GetOptionName(p, end, wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION);
 }
 
-static wxString GetLongOptionName(const wxChar *p)
+static wxString GetLongOptionName(wxString::const_iterator p,
+                                  wxString::const_iterator end)
 {
-    return GetOptionName(p, wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION);
+    return GetOptionName(p, end, wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION);
 }
 
 #endif // wxUSE_CMDLINE_PARSER
@@ -1188,7 +1200,7 @@ static wxString GetLongOptionName(const wxChar *p)
  */
 
 /* static */
-wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxChar *p)
+wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxString& cmdline)
 {
     wxArrayString args;
 
@@ -1196,14 +1208,17 @@ wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxChar *p)
     arg.reserve(1024);
 
     bool isInsideQuotes = false;
+
+    wxString::const_iterator p = cmdline.begin();
+
     for ( ;; )
     {
         // skip white space
-        while ( *p == _T(' ') || *p == _T('\t') )
-            p++;
+        while ( p != cmdline.end() && (*p == _T(' ') || *p == _T('\t')) )
+            ++p;
 
         // anything left?
-        if ( *p == _T('\0') )
+        if ( p == cmdline.end() )
             break;
 
         // parse this parameter
@@ -1211,7 +1226,7 @@ wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxChar *p)
         bool lastBS = false;
         for ( arg.clear(); !endParam; p++ )
         {
-            switch ( *p )
+            switch ( (*p).GetValue() )
             {
                 case _T('"'):
                     if ( !lastBS )
diff --git a/src/common/config.cpp b/src/common/config.cpp
index e7e62a34bb..c4ae2ed8d1 100644
--- a/src/common/config.cpp
+++ b/src/common/config.cpp
@@ -264,7 +264,7 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer,
 
         /* JACS: work around a memory bug that causes an assert
            when using wxRegConfig, related to reference-counting.
-           Can be reproduced by removing (const wxChar*) below and
+           Can be reproduced by removing .wc_str() below and
            adding the following code to the config sample OnInit under
            Windows:
 
@@ -273,7 +273,7 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer,
            int value;
            pConfig->Read(_T("MainWindowX"), & value);
         */
-        m_strOldPath = (const wxChar*) m_pContainer->GetPath();
+        m_strOldPath = m_pContainer->GetPath().wc_str();
         if ( *m_strOldPath.c_str() != wxCONFIG_PATH_SEPARATOR )
           m_strOldPath += wxCONFIG_PATH_SEPARATOR;
         m_pContainer->SetPath(strPath);
@@ -399,19 +399,20 @@ wxString wxExpandEnvVars(const wxString& str)
           wxString strVarName(str.c_str() + n + 1, m - n - 1);
 
 #ifdef __WXWINCE__
-          const wxChar *pszValue = NULL;
+          const bool expanded = false;
 #else
           // NB: use wxGetEnv instead of wxGetenv as otherwise variables
           //     set through wxSetEnv may not be read correctly!
-          const wxChar *pszValue = NULL;
+          bool expanded = false;
           wxString tmp;
           if (wxGetEnv(strVarName, &tmp))
-              pszValue = tmp;
-#endif
-          if ( pszValue != NULL ) {
-            strResult += pszValue;
+          {
+              strResult += tmp;
+              expanded = true;
           }
-          else {
+          else
+#endif
+          {
             // variable doesn't exist => don't change anything
             #ifdef  __WXMSW__
               if ( bracket != Bracket_Windows )
@@ -437,7 +438,7 @@ wxString wxExpandEnvVars(const wxString& str)
             }
             else {
               // skip closing bracket unless the variables wasn't expanded
-              if ( pszValue == NULL )
+              if ( !expanded )
                 strResult << (wxChar)bracket;
               m++;
             }
@@ -466,21 +467,21 @@ wxString wxExpandEnvVars(const wxString& str)
 }
 
 // this function is used to properly interpret '..' in path
-void wxSplitPath(wxArrayString& aParts, const wxChar *sz)
+void wxSplitPath(wxArrayString& aParts, const wxString& path)
 {
   aParts.clear();
 
   wxString strCurrent;
-  const wxChar *pc = sz;
+  wxString::const_iterator pc = path.begin();
   for ( ;; ) {
-    if ( *pc == wxT('\0') || *pc == wxCONFIG_PATH_SEPARATOR ) {
+    if ( pc == path.end() || *pc == wxCONFIG_PATH_SEPARATOR ) {
       if ( strCurrent == wxT(".") ) {
         // ignore
       }
       else if ( strCurrent == wxT("..") ) {
         // go up one level
         if ( aParts.size() == 0 )
-          wxLogWarning(_("'%s' has extra '..', ignored."), sz);
+          wxLogWarning(_("'%s' has extra '..', ignored."), path);
         else
           aParts.erase(aParts.end() - 1);
 
@@ -493,12 +494,12 @@ void wxSplitPath(wxArrayString& aParts, const wxChar *sz)
       //else:
         // could log an error here, but we prefer to ignore extra '/'
 
-      if ( *pc == wxT('\0') )
+      if ( pc == path.end() )
         break;
     }
     else
       strCurrent += *pc;
 
-    pc++;
+    ++pc;
   }
 }
diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp
index 249af182a6..f42c88530e 100644
--- a/src/common/dcbase.cpp
+++ b/src/common/dcbase.cpp
@@ -2172,9 +2172,9 @@ void wxDCBase::GetMultiLineTextExtent(const wxString& text,
             heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
 
     wxString curLine;
-    for ( const wxChar *pc = text; ; pc++ )
+    for ( wxString::const_iterator pc = text.begin(); ; ++pc )
     {
-        if ( *pc == _T('\n') || *pc == _T('\0') )
+        if ( pc == text.end() || *pc == _T('\n') )
         {
             if ( curLine.empty() )
             {
@@ -2205,14 +2205,13 @@ void wxDCBase::GetMultiLineTextExtent(const wxString& text,
                 heightTextTotal += heightLine;
             }
 
-            if ( *pc == _T('\n') )
+            if ( pc == text.end() )
             {
-               curLine.clear();
+               break;
             }
-            else
+            else // '\n'
             {
-               // the end of string
-               break;
+               curLine.clear();
             }
         }
         else
diff --git a/src/common/docview.cpp b/src/common/docview.cpp
index 41b31fb23e..1ebad15e2b 100644
--- a/src/common/docview.cpp
+++ b/src/common/docview.cpp
@@ -112,7 +112,7 @@ static const wxChar *s_MRUEntryFormat = wxT("&%d %s");
 // local functions
 // ----------------------------------------------------------------------------
 
-static wxString FindExtension(const wxChar *path)
+static wxString FindExtension(const wxString& path)
 {
     wxString ext;
     wxSplitPath(path, NULL, NULL, &ext);
@@ -456,8 +456,7 @@ bool wxDocument::OnSaveModified()
             msgTitle = wxString(_("Warning"));
 
         wxString prompt;
-        prompt.Printf(_("Do you want to save changes to document %s?"),
-                (const wxChar *)title);
+        prompt.Printf(_("Do you want to save changes to document %s?"), title);
         int res = wxMessageBox(prompt, msgTitle,
                 wxYES_NO|wxCANCEL|wxICON_QUESTION,
                 GetDocumentWindow());
diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp
index 2157246df3..5d99bf67fd 100644
--- a/src/common/dynarray.cpp
+++ b/src/common/dynarray.cpp
@@ -427,17 +427,31 @@ _WX_DEFINE_BASEARRAY(wxString, wxBaseArrayStringBase)
 // extern "C" functions and the functions with C++ linkage and ptr_fun and
 // wxStringCompareLess can't take wxStrcmp/wxStricmp directly as arguments in
 // this case, we need the wrappers below to make this work
-inline int wxStrcmpCppWrapper(const wxChar *p, const wxChar *q)
+struct wxStringCmp
 {
-    return wxStrcmp(p, q);
-}
+    typedef wxString first_argument_type;
+    typedef wxString second_argument_type;
+    typedef int result_type;
+
+    int operator()(const wxString& s1, const wxString& s2) const
+    {
+        return s1.compare(s2);
+    }
+};
 
-inline int wxStricmpCppWrapper(const wxChar *p, const wxChar *q)
+struct wxStringCmpNoCase
 {
-    return wxStricmp(p, q);
-}
+    typedef wxString first_argument_type;
+    typedef wxString second_argument_type;
+    typedef int result_type;
 
-int wxArrayString::Index(const wxChar* sz, bool bCase, bool WXUNUSED(bFromEnd)) const
+    int operator()(const wxString& s1, const wxString& s2) const
+    {
+        return s1.CmpNoCase(s2);
+    }
+};
+
+int wxArrayString::Index(const wxString& str, bool bCase, bool WXUNUSED(bFromEnd)) const
 {
     wxArrayString::const_iterator it;
 
@@ -446,14 +460,14 @@ int wxArrayString::Index(const wxChar* sz, bool bCase, bool WXUNUSED(bFromEnd))
         it = std::find_if(begin(), end(),
                           std::not1(
                               std::bind2nd(
-                                  std::ptr_fun(wxStrcmpCppWrapper), sz)));
+                                  wxStringCmp(), str)));
     }
     else // !bCase
     {
         it = std::find_if(begin(), end(),
                           std::not1(
                               std::bind2nd(
-                                  std::ptr_fun(wxStricmpCppWrapper), sz)));
+                                  wxStringCmpNoCase(), str)));
     }
 
     return it == end() ? wxNOT_FOUND : it - begin();
@@ -464,8 +478,6 @@ class wxStringCompareLess
 {
 public:
     wxStringCompareLess(F f) : m_f(f) { }
-    bool operator()(const wxChar* s1, const wxChar* s2)
-        { return m_f(s1, s2) < 0; }
     bool operator()(const wxString& s1, const wxString& s2)
         { return m_f(s1, s2) < 0; }
 private:
@@ -495,33 +507,32 @@ void wxArrayString::Sort(bool reverseOrder)
     }
 }
 
-int wxSortedArrayString::Index(const wxChar* sz, bool bCase, bool WXUNUSED(bFromEnd)) const
+int wxSortedArrayString::Index(const wxString& str, bool bCase, bool WXUNUSED(bFromEnd)) const
 {
     wxSortedArrayString::const_iterator it;
-    wxString s(sz);
 
     if (bCase)
-        it = std::lower_bound(begin(), end(), s,
-                              wxStringCompare(wxStrcmpCppWrapper));
+        it = std::lower_bound(begin(), end(), str,
+                              wxStringCompare(wxStringCmp()));
     else
-        it = std::lower_bound(begin(), end(), s,
-                              wxStringCompare(wxStricmpCppWrapper));
+        it = std::lower_bound(begin(), end(), str,
+                              wxStringCompare(wxStringCmpNoCase()));
 
     if (it == end())
         return wxNOT_FOUND;
 
     if (bCase)
     {
-        if (wxStrcmp(it->c_str(), sz) != 0)
+        if (str.Cmp(*it) != 0)
             return wxNOT_FOUND;
     }
     else
     {
-        if (wxStricmp(it->c_str(), sz) != 0)
+        if (str.CmpNoCase(*it) != 0)
             return wxNOT_FOUND;
     }
 
     return it - begin();
 }
 
-#endif
+#endif // wxUSE_STL
diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp
index 0c3912dbdb..bc153a0a9f 100644
--- a/src/common/fileconf.cpp
+++ b/src/common/fileconf.cpp
@@ -222,12 +222,12 @@ public:
   bool  IsEmpty() const { return Entries().IsEmpty() && Groups().IsEmpty(); }
 
   // find entry/subgroup (NULL if not found)
-  wxFileConfigGroup *FindSubgroup(const wxChar *szName) const;
-  wxFileConfigEntry *FindEntry   (const wxChar *szName) const;
+  wxFileConfigGroup *FindSubgroup(const wxString& name) const;
+  wxFileConfigEntry *FindEntry   (const wxString& name) const;
 
   // delete entry/subgroup, return false if doesn't exist
-  bool DeleteSubgroupByName(const wxChar *szName);
-  bool DeleteEntry(const wxChar *szName);
+  bool DeleteSubgroupByName(const wxString& name);
+  bool DeleteEntry(const wxString& name);
 
   // create new entry/subgroup returning pointer to newly created element
   wxFileConfigGroup *AddSubgroup(const wxString& strName);
@@ -536,15 +536,16 @@ wxFileConfig::~wxFileConfig()
 
 void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
 {
-  const wxChar *pStart;
-  const wxChar *pEnd;
-  wxString strLine;
 
   size_t nLineCount = buffer.GetLineCount();
 
   for ( size_t n = 0; n < nLineCount; n++ )
   {
-    strLine = buffer[n];
+    wxString strLine = buffer[n];
+    // FIXME-UTF8: rewrite using iterators, without this buffer
+    wxWxCharBuffer buf(strLine.c_str());
+    const wxChar *pStart;
+    const wxChar *pEnd;
 
     // add the line to linked list
     if ( bLocal )
@@ -560,7 +561,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
 
 
     // skip leading spaces
-    for ( pStart = strLine; wxIsspace(*pStart); pStart++ )
+    for ( pStart = buf; wxIsspace(*pStart); pStart++ )
       ;
 
     // skip blank/comment lines
@@ -1059,7 +1060,7 @@ bool wxFileConfig::Save(wxOutputStream& os, const wxMBConv& conv)
 bool wxFileConfig::RenameEntry(const wxString& oldName,
                                const wxString& newName)
 {
-    wxASSERT_MSG( !wxStrchr(oldName, wxCONFIG_PATH_SEPARATOR),
+    wxASSERT_MSG( oldName.find(wxCONFIG_PATH_SEPARATOR) == wxString::npos,
                    _T("RenameEntry(): paths are not supported") );
 
     // check that the entry exists
@@ -1148,7 +1149,8 @@ bool wxFileConfig::DeleteAll()
 
   if ( m_fnLocalFile.IsOk() )
   {
-      if ( m_fnLocalFile.FileExists() && wxRemove(m_fnLocalFile.GetFullPath()) == -1 )
+      if ( m_fnLocalFile.FileExists() &&
+           !wxRemoveFile(m_fnLocalFile.GetFullPath()) )
       {
           wxLogSysError(_("can't delete user configuration file '%s'"),
                         m_fnLocalFile.GetFullPath().c_str());
@@ -1548,7 +1550,7 @@ wxString wxFileConfigGroup::GetFullName() const
 
 // use binary search because the array is sorted
 wxFileConfigEntry *
-wxFileConfigGroup::FindEntry(const wxChar *szName) const
+wxFileConfigGroup::FindEntry(const wxString& name) const
 {
   size_t i,
        lo = 0,
@@ -1561,9 +1563,9 @@ wxFileConfigGroup::FindEntry(const wxChar *szName) const
     pEntry = m_aEntries[i];
 
     #if wxCONFIG_CASE_SENSITIVE
-      res = wxStrcmp(pEntry->Name(), szName);
+      res = pEntry->Name().compare(name);
     #else
-      res = wxStricmp(pEntry->Name(), szName);
+      res = pEntry->Name().CmpNoCase(name);
     #endif
 
     if ( res > 0 )
@@ -1578,7 +1580,7 @@ wxFileConfigGroup::FindEntry(const wxChar *szName) const
 }
 
 wxFileConfigGroup *
-wxFileConfigGroup::FindSubgroup(const wxChar *szName) const
+wxFileConfigGroup::FindSubgroup(const wxString& name) const
 {
   size_t i,
        lo = 0,
@@ -1591,9 +1593,9 @@ wxFileConfigGroup::FindSubgroup(const wxChar *szName) const
     pGroup = m_aSubgroups[i];
 
     #if wxCONFIG_CASE_SENSITIVE
-      res = wxStrcmp(pGroup->Name(), szName);
+      res = pGroup->Name().compare(name);
     #else
-      res = wxStricmp(pGroup->Name(), szName);
+      res = pGroup->Name().CmpNoCase(name);
     #endif
 
     if ( res > 0 )
@@ -1644,9 +1646,9 @@ wxFileConfigGroup *wxFileConfigGroup::AddSubgroup(const wxString& strName)
   delete several of them.
  */
 
-bool wxFileConfigGroup::DeleteSubgroupByName(const wxChar *szName)
+bool wxFileConfigGroup::DeleteSubgroupByName(const wxString& name)
 {
-    wxFileConfigGroup * const pGroup = FindSubgroup(szName);
+    wxFileConfigGroup * const pGroup = FindSubgroup(name);
 
     return pGroup ? DeleteSubgroup(pGroup) : false;
 }
@@ -1765,9 +1767,9 @@ bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup)
     return true;
 }
 
-bool wxFileConfigGroup::DeleteEntry(const wxChar *szName)
+bool wxFileConfigGroup::DeleteEntry(const wxString& name)
 {
-  wxFileConfigEntry *pEntry = FindEntry(szName);
+  wxFileConfigEntry *pEntry = FindEntry(name);
   if ( !pEntry )
   {
       // entry doesn't exist, nothing to do
@@ -1920,18 +1922,18 @@ void wxFileConfigEntry::SetValue(const wxString& strValue, bool bUser)
 int CompareEntries(wxFileConfigEntry *p1, wxFileConfigEntry *p2)
 {
 #if wxCONFIG_CASE_SENSITIVE
-    return wxStrcmp(p1->Name(), p2->Name());
+    return p1->Name().compare(p2->Name());
 #else
-    return wxStricmp(p1->Name(), p2->Name());
+    return p1->Name().CmpNoCase(p2->Name());
 #endif
 }
 
 int CompareGroups(wxFileConfigGroup *p1, wxFileConfigGroup *p2)
 {
 #if wxCONFIG_CASE_SENSITIVE
-    return wxStrcmp(p1->Name(), p2->Name());
+    return p1->Name().compare(p2->Name());
 #else
-    return wxStricmp(p1->Name(), p2->Name());
+    return p1->Name().CmpNoCase(p2->Name());
 #endif
 }
 
diff --git a/src/common/filename.cpp b/src/common/filename.cpp
index 3c5764a6bb..6334696a34 100644
--- a/src/common/filename.cpp
+++ b/src/common/filename.cpp
@@ -767,7 +767,7 @@ static wxString wxCreateTempImpl(
     path += _T("XXXXXX");
 
     // we need to copy the path to the buffer in which mkstemp() can modify it
-    wxCharBuffer buf( wxConvFile.cWX2MB( path ) );
+    wxCharBuffer buf(path.fn_str());
 
     // cast is safe because the string length doesn't change
     int fdTemp = mkstemp( (char*)(const char*) buf );
diff --git a/src/common/filtfind.cpp b/src/common/filtfind.cpp
index bd7d5a6c8a..c72cc6f47d 100644
--- a/src/common/filtfind.cpp
+++ b/src/common/filtfind.cpp
@@ -23,7 +23,7 @@
 // the filter classes they use.
 
 const wxFilterClassFactory *
-wxFilterClassFactory::Find(const wxChar *protocol, wxStreamProtocolType type)
+wxFilterClassFactory::Find(const wxString& protocol, wxStreamProtocolType type)
 {
     for (const wxFilterClassFactory *f = GetFirst(); f; f = f->GetNext())
         if (f->CanHandle(protocol, type))
diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp
index da7c72171e..6455c2390e 100644
--- a/src/common/ftp.cpp
+++ b/src/common/ftp.cpp
@@ -314,7 +314,7 @@ char wxFTP::GetResult()
             }
             else // subsequent line of multiline reply
             {
-                if ( wxStrncmp(line, code, LEN_CODE) == 0 )
+                if ( line.compare(0, LEN_CODE, code) == 0 )
                 {
                     if ( chMarker == _T(' ') )
                     {
@@ -378,7 +378,7 @@ bool wxFTP::SetTransferMode(TransferMode transferMode)
 
     if ( !DoSimpleCommand(_T("TYPE"), mode) )
     {
-        wxLogError(_("Failed to set FTP transfer mode to %s."), (const wxChar*)
+        wxLogError(_("Failed to set FTP transfer mode to %s."),
                    (transferMode == ASCII ? _("ASCII") : _("binary")));
 
         return false;
@@ -707,18 +707,20 @@ wxSocketBase *wxFTP::GetPassivePort()
         return NULL;
     }
 
-    const wxChar *addrStart = wxStrchr(m_lastResult, _T('('));
-    const wxChar *addrEnd = addrStart ? wxStrchr(addrStart, _T(')')) : NULL;
-    if ( !addrEnd )
+    size_t addrStart = m_lastResult.find(_T('('));
+    size_t addrEnd = (addrStart == wxString::npos)
+                     ? wxString::npos
+                     : m_lastResult.find(_T(')'), addrStart);
+
+    if ( addrEnd == wxString::npos )
     {
         m_lastError = wxPROTO_PROTERR;
-
         return NULL;
     }
 
     // get the port number and address
     int a[6];
-    wxString straddr(addrStart + 1, addrEnd);
+    wxString straddr(m_lastResult, addrStart + 1, addrEnd - (addrStart + 1));
     wxSscanf(straddr, wxT("%d,%d,%d,%d,%d,%d"),
              &a[2],&a[3],&a[4],&a[5],&a[0],&a[1]);
 
diff --git a/src/common/http.cpp b/src/common/http.cpp
index f8977ecedf..5a185bf899 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -75,7 +75,7 @@ wxHTTP::wxHeaderIterator wxHTTP::FindHeader(const wxString& header)
     wxHeaderIterator it = m_headers.begin();
     for ( wxHeaderIterator en = m_headers.end(); it != en; ++it )
     {
-        if ( wxStricmp(it->first, header) == 0 )
+        if ( header.CmpNoCase(it->first) == 0 )
             break;
     }
 
@@ -87,7 +87,7 @@ wxHTTP::wxHeaderConstIterator wxHTTP::FindHeader(const wxString& header) const
     wxHeaderConstIterator it = m_headers.begin();
     for ( wxHeaderConstIterator en = m_headers.end(); it != en; ++it )
     {
-        if ( wxStricmp(it->first, header) == 0 )
+        if ( header.CmpNoCase(it->first) == 0 )
             break;
     }
 
@@ -274,8 +274,8 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req)
 
     wxString buf;
     buf.Printf(wxT("%s %s HTTP/1.0\r\n"), request, path.c_str());
-    const wxWX2MBbuf pathbuf = wxConvLocal.cWX2MB(buf);
-    Write(pathbuf, strlen(wxMBSTRINGCAST pathbuf));
+    const wxWX2MBbuf pathbuf = buf.mb_str();
+    Write(pathbuf, strlen(pathbuf));
     SendHeaders();
     Write("\r\n", 2);
 
@@ -407,7 +407,7 @@ wxInputStream *wxHTTP::GetInputStream(const wxString& path)
     inp_stream = new wxHTTPStream(this);
 
     if (!GetHeader(wxT("Content-Length")).empty())
-        inp_stream->m_httpsize = wxAtoi(WXSTRINGCAST GetHeader(wxT("Content-Length")));
+        inp_stream->m_httpsize = wxAtoi(GetHeader(wxT("Content-Length")));
     else
         inp_stream->m_httpsize = (size_t)-1;
 
diff --git a/src/common/image.cpp b/src/common/image.cpp
index d91c445e04..1c30e71c92 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -2231,7 +2231,7 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int ind
 
     if (stream.IsSeekable() && !handler->CanRead(stream))
     {
-        wxLogError(_("Image file is not of type %s."), (const wxChar*) mimetype);
+        wxLogError(_("Image file is not of type %s."), mimetype);
         return false;
     }
     else
diff --git a/src/common/sstream.cpp b/src/common/sstream.cpp
index f92916a667..7d276e665b 100644
--- a/src/common/sstream.cpp
+++ b/src/common/sstream.cpp
@@ -38,27 +38,20 @@
 
 // TODO:  Do we want to include the null char in the stream?  If so then
 // just add +1 to m_len in the ctor 
-wxStringInputStream::wxStringInputStream(const wxString& s) 
+wxStringInputStream::wxStringInputStream(const wxString& s)
 #if wxUSE_UNICODE
-    : m_str(s), m_buf(wxMBConvUTF8().cWX2MB(s).release()), m_len(strlen(m_buf))
+    // FIXME-UTF8: use wxCharBufferWithLength if we have it
+    : m_str(s), m_buf(s.utf8_str()), m_len(strlen(m_buf))
 #else
-    : m_str(s), m_buf((char*)(const char*)s.c_str()), m_len(s.length())
+    : m_str(s), m_buf(s.mb_str()), m_len(s.length())
 #endif
 {
 #if wxUSE_UNICODE
-    wxASSERT_MSG(m_buf != NULL, _T("Could not convert string to UTF8!"));
+    wxASSERT_MSG(m_buf.data() != NULL, _T("Could not convert string to UTF8!"));
 #endif
     m_pos = 0;
 }
 
-wxStringInputStream::~wxStringInputStream()
-{
-#if wxUSE_UNICODE
-    // Note: wx[W]CharBuffer uses malloc()/free()
-    free(m_buf);
-#endif
-}
-
 // ----------------------------------------------------------------------------
 // getlength
 // ----------------------------------------------------------------------------
@@ -126,7 +119,7 @@ size_t wxStringInputStream::OnSysRead(void *buffer, size_t size)
         size = sizeMax;
     }
 
-    memcpy(buffer, m_buf + m_pos, size);
+    memcpy(buffer, m_buf.data() + m_pos, size);
     m_pos += size;
 
     return size;
diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp
index 96f4b27ce7..62af673a0e 100644
--- a/src/common/strconv.cpp
+++ b/src/common/strconv.cpp
@@ -476,10 +476,10 @@ size_t wxMBConvLibc::WC2MB(char *buf, const wchar_t *psz, size_t n) const
 
 #ifdef __UNIX__
 
-wxConvBrokenFileNames::wxConvBrokenFileNames(const wxChar *charset)
+wxConvBrokenFileNames::wxConvBrokenFileNames(const wxString& charset)
 {
-    if ( !charset || wxStricmp(charset, _T("UTF-8")) == 0
-                  || wxStricmp(charset, _T("UTF8")) == 0  )
+    if ( wxStricmp(charset, _T("UTF-8")) == 0 ||
+         wxStricmp(charset, _T("UTF8")) == 0  )
         m_conv = new wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_PUA);
     else
         m_conv = new wxCSConv(charset);
@@ -1588,7 +1588,7 @@ wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen,
 class wxMBConv_iconv : public wxMBConv
 {
 public:
-    wxMBConv_iconv(const wxChar *name);
+    wxMBConv_iconv(const char *name);
     virtual ~wxMBConv_iconv();
 
     virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const;
@@ -1603,7 +1603,7 @@ public:
 
     virtual wxMBConv *Clone() const
     {
-        wxMBConv_iconv *p = new wxMBConv_iconv(m_name);
+        wxMBConv_iconv *p = new wxMBConv_iconv(m_name.ToAscii());
         p->m_minMBCharWidth = m_minMBCharWidth;
         return p;
     }
@@ -1641,7 +1641,7 @@ private:
 };
 
 // make the constructor available for unit testing
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name )
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name )
 {
     wxMBConv_iconv* result = new wxMBConv_iconv( name );
     if ( !result->IsOk() )
@@ -1656,15 +1656,11 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name )
 wxString wxMBConv_iconv::ms_wcCharsetName;
 bool wxMBConv_iconv::ms_wcNeedsSwap = false;
 
-wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
+wxMBConv_iconv::wxMBConv_iconv(const char *name)
               : m_name(name)
 {
     m_minMBCharWidth = 0;
 
-    // iconv operates with chars, not wxChars, but luckily it uses only ASCII
-    // names for the charsets
-    const wxCharBuffer cname(wxString(name).ToAscii());
-
     // check for charset that represents wchar_t:
     if ( ms_wcCharsetName.empty() )
     {
@@ -1701,13 +1697,13 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
             wxLogTrace(TRACE_STRCONV, _T("  trying charset \"%s\""),
                        nameXE.c_str());
 
-            m2w = iconv_open(nameXE.ToAscii(), cname);
+            m2w = iconv_open(nameXE.ToAscii(), name);
             if ( m2w == ICONV_T_INVALID )
             {
                 // try charset w/o bytesex info (e.g. "UCS4")
                 wxLogTrace(TRACE_STRCONV, _T("  trying charset \"%s\""),
                            nameCS.c_str());
-                m2w = iconv_open(nameCS.ToAscii(), cname);
+                m2w = iconv_open(nameCS.ToAscii(), name);
 
                 // and check for bytesex ourselves:
                 if ( m2w != ICONV_T_INVALID )
@@ -1757,7 +1753,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
     }
     else // we already have ms_wcCharsetName
     {
-        m2w = iconv_open(ms_wcCharsetName.ToAscii(), cname);
+        m2w = iconv_open(ms_wcCharsetName.ToAscii(), name);
     }
 
     if ( ms_wcCharsetName.empty() )
@@ -1766,12 +1762,12 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
     }
     else
     {
-        w2m = iconv_open(cname, ms_wcCharsetName.ToAscii());
+        w2m = iconv_open(name, ms_wcCharsetName.ToAscii());
         if ( w2m == ICONV_T_INVALID )
         {
             wxLogTrace(TRACE_STRCONV,
                        wxT("\"%s\" -> \"%s\" works but not the converse!?"),
-                       ms_wcCharsetName.c_str(), cname.data());
+                       ms_wcCharsetName.c_str(), name);
         }
     }
 }
@@ -1982,8 +1978,8 @@ size_t wxMBConv_iconv::GetMBNulLen() const
 #if wxUSE_UNICODE_UTF8
 bool wxMBConv_iconv::IsUTF8() const
 {
-    return wxStricmp(m_name, _T("UTF-8")) == 0 ||
-           wxStricmp(m_name, _T("UTF8")) == 0;
+    return wxStricmp(m_name, "UTF-8") == 0 ||
+           wxStricmp(m_name, "UTF8") == 0;
 }
 #endif
 
@@ -1998,7 +1994,7 @@ bool wxMBConv_iconv::IsUTF8() const
 
 // from utils.cpp
 #if wxUSE_FONTMAP
-extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const wxChar *charset);
+extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const char *charset);
 extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding);
 #endif
 
@@ -2019,7 +2015,7 @@ public:
     }
 
 #if wxUSE_FONTMAP
-    wxMBConv_win32(const wxChar* name)
+    wxMBConv_win32(const char* name)
     {
         m_CodePage = wxCharsetToCodepage(name);
         m_minMBCharWidth = 0;
@@ -3107,7 +3103,7 @@ private:
 public:
     // temporarily just use wxEncodingConverter stuff,
     // so that it works while a better implementation is built
-    wxMBConv_wxwin(const wxChar* name)
+    wxMBConv_wxwin(const char* name)
     {
         if (name)
             m_enc = wxFontMapperBase::Get()->CharsetToEncoding(name, false);
@@ -3180,7 +3176,7 @@ private:
 };
 
 // make the constructors available for unit testing
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name )
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name )
 {
     wxMBConv_wxwin* result = new wxMBConv_wxwin( name );
     if ( !result->IsOk() )
@@ -3205,13 +3201,13 @@ void wxCSConv::Init()
     m_deferred = true;
 }
 
-wxCSConv::wxCSConv(const wxChar *charset)
+wxCSConv::wxCSConv(const wxString& charset)
 {
     Init();
 
-    if ( charset )
+    if ( !charset.empty() )
     {
-        SetName(charset);
+        SetName(charset.ToAscii());
     }
 
 #if wxUSE_FONTMAP
@@ -3268,11 +3264,11 @@ void wxCSConv::Clear()
     m_convReal = NULL;
 }
 
-void wxCSConv::SetName(const wxChar *charset)
+void wxCSConv::SetName(const char *charset)
 {
     if (charset)
     {
-        m_name = wxStrdup(charset);
+        m_name = strdup(charset);
         m_deferred = true;
     }
 }
@@ -3291,7 +3287,7 @@ wxMBConv *wxCSConv::DoCreate() const
     wxLogTrace(TRACE_STRCONV,
                wxT("creating conversion for %s"),
                (m_name ? m_name
-                       : (const wxChar*)wxFontMapperBase::GetEncodingName(m_encoding).c_str()));
+                       : (const char*)wxFontMapperBase::GetEncodingName(m_encoding).mb_str()));
 #endif // wxUSE_FONTMAP
 
     // check for the special case of ASCII or ISO8859-1 charset: as we have
@@ -3318,14 +3314,13 @@ wxMBConv *wxCSConv::DoCreate() const
     if ( m_name )
 #endif // !wxUSE_FONTMAP
     {
-        wxString name(m_name);
 #if wxUSE_FONTMAP
         wxFontEncoding encoding(m_encoding);
 #endif
 
-        if ( !name.empty() )
+        if ( m_name )
         {
-            wxMBConv_iconv *conv = new wxMBConv_iconv(name);
+            wxMBConv_iconv *conv = new wxMBConv_iconv(m_name);
             if ( conv->IsOk() )
                 return conv;
 
@@ -3333,7 +3328,7 @@ wxMBConv *wxCSConv::DoCreate() const
 
 #if wxUSE_FONTMAP
             encoding =
-                wxFontMapperBase::Get()->CharsetToEncoding(name, false);
+                wxFontMapperBase::Get()->CharsetToEncoding(m_name, false);
 #endif // wxUSE_FONTMAP
         }
 #if wxUSE_FONTMAP
@@ -3344,7 +3339,7 @@ wxMBConv *wxCSConv::DoCreate() const
                 if ( it->second.empty() )
                     return NULL;
 
-                wxMBConv_iconv *conv = new wxMBConv_iconv(it->second);
+                wxMBConv_iconv *conv = new wxMBConv_iconv(it->second.ToAscii());
                 if ( conv->IsOk() )
                     return conv;
 
@@ -3352,15 +3347,19 @@ wxMBConv *wxCSConv::DoCreate() const
             }
 
             const wxChar** names = wxFontMapperBase::GetAllEncodingNames(encoding);
-            // CS : in case this does not return valid names (eg for MacRoman) encoding
-            // got a 'failure' entry in the cache all the same, although it just has to
-            // be created using a different method, so only store failed iconv creation
-            // attempts (or perhaps we shoulnd't do this at all ?)
+            // CS : in case this does not return valid names (eg for MacRoman)
+            // encoding got a 'failure' entry in the cache all the same,
+            // although it just has to be created using a different method, so
+            // only store failed iconv creation attempts (or perhaps we
+            // shoulnd't do this at all ?)
             if ( names[0] != NULL )
             {
                 for ( ; *names; ++names )
                 {
-                    wxMBConv_iconv *conv = new wxMBConv_iconv(*names);
+                    // FIXME-UTF8: wxFontMapperBase::GetAllEncodingNames()
+                    //             will need changes that will obsolete this
+                    wxString name(*names);
+                    wxMBConv_iconv *conv = new wxMBConv_iconv(name.ToAscii());
                     if ( conv->IsOk() )
                     {
                         gs_nameCache[encoding] = *names;
@@ -3494,9 +3493,9 @@ wxMBConv *wxCSConv::DoCreate() const
                    m_name ? m_name
                       :
 #if wxUSE_FONTMAP
-                         (const wxChar*)wxFontMapperBase::GetEncodingDescription(m_encoding).c_str()
+                         (const char*)wxFontMapperBase::GetEncodingDescription(m_encoding).ToAscii()
 #else // !wxUSE_FONTMAP
-                         (const wxChar*)wxString::Format(_("encoding %i"), m_encoding).c_str()
+                         (const char*)wxString::Format(_("encoding %i"), m_encoding).ToAscii()
 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
               );
 
diff --git a/src/common/stream.cpp b/src/common/stream.cpp
index e3d076ad77..32e6fe8d15 100644
--- a/src/common/stream.cpp
+++ b/src/common/stream.cpp
@@ -1156,29 +1156,25 @@ wxString wxFilterClassFactoryBase::PopExtension(const wxString& location) const
 }
 
 wxString::size_type wxFilterClassFactoryBase::FindExtension(
-        const wxChar *location) const
+        const wxString& location) const
 {
-    size_t len = wxStrlen(location);
-
     for (const wxChar *const *p = GetProtocols(wxSTREAM_FILEEXT); *p; p++)
     {
-        size_t l = wxStrlen(*p);
-
-        if (l <= len && wxStrcmp(*p, location + len - l) == 0)
-            return len - l;
+        if ( location.EndsWith(*p) )
+            return location.length() - wxStrlen(*p);
     }
 
     return wxString::npos;
 }
 
-bool wxFilterClassFactoryBase::CanHandle(const wxChar *protocol,
+bool wxFilterClassFactoryBase::CanHandle(const wxString& protocol,
                                          wxStreamProtocolType type) const
 {
     if (type == wxSTREAM_FILEEXT)
         return FindExtension(protocol) != wxString::npos;
     else
         for (const wxChar *const *p = GetProtocols(type); *p; p++)
-            if (wxStrcmp(*p, protocol) == 0)
+            if (protocol == *p)
                 return true;
 
     return false;
diff --git a/src/common/tarstrm.cpp b/src/common/tarstrm.cpp
index 400a4e3989..65a4099d41 100644
--- a/src/common/tarstrm.cpp
+++ b/src/common/tarstrm.cpp
@@ -829,8 +829,8 @@ wxTarNumber wxTarInputStream::GetHeaderNumber(int id) const
 
     if ((value = GetExtendedHeader(m_hdr->Name(id))) != wxEmptyString) {
         wxTarNumber n = 0;
-        const wxChar *p = value;
-        while (*p == ' ')
+        wxString::const_iterator p = value.begin();
+        while (*p == ' ' && p != value.end())
             p++;
         while (isdigit(*p))
             n = n * 10 + (*p++ - '0');
diff --git a/src/common/txtstrm.cpp b/src/common/txtstrm.cpp
index d2e08f5c8f..524402d54f 100644
--- a/src/common/txtstrm.cpp
+++ b/src/common/txtstrm.cpp
@@ -416,7 +416,8 @@ void wxTextOutputStream::WriteString(const wxString& string)
     }
 
 #if wxUSE_UNICODE
-    wxCharBuffer buffer = m_conv->cWC2MB(out, out.length(), &len);
+    // FIXME-UTF8: use wxCharBufferWithLength if/when we have it
+    wxCharBuffer buffer = m_conv->cWC2MB(out.wc_str(), out.length(), &len);
     m_output.Write(buffer, len);
 #else
     m_output.Write(out.c_str(), out.length() );
diff --git a/src/common/uri.cpp b/src/common/uri.cpp
index a5151947ef..5ddfbc3cbc 100644
--- a/src/common/uri.cpp
+++ b/src/common/uri.cpp
@@ -93,7 +93,10 @@ const wxChar* wxURI::Create(const wxString& uri)
     if (m_fields)
         Clear();
 
-    return Parse(uri);
+    // FIXME-UTF8: rewrite ParseXXX() methods using iterators
+    // NB: using wxWxCharBuffer instead of just c_str() avoids keeping
+    //     converted string in memory for longer than needed
+    return Parse(wxWxCharBuffer(uri.c_str()));
 }
 
 // ---------------------------------------------------------------------------
@@ -374,7 +377,7 @@ bool wxURI::IsReference() const
 // URI-reference = URI / relative
 // ---------------------------------------------------------------------------
 
-const wxChar* wxURI::Parse(const wxChar* uri)
+const wxChar* wxURI::Parse(const wxChar *uri)
 {
     uri = ParseScheme(uri);
     uri = ParseAuthority(uri);
@@ -389,7 +392,7 @@ const wxChar* wxURI::Parse(const wxChar* uri)
 // Individual parsers for each URI component
 // ---------------------------------------------------------------------------
 
-const wxChar* wxURI::ParseScheme(const wxChar* uri)
+const wxChar* wxURI::ParseScheme(const wxChar *uri)
 {
     wxASSERT(uri != NULL);
 
diff --git a/src/common/zipstrm.cpp b/src/common/zipstrm.cpp
index aa3568f0d5..c960f548e3 100644
--- a/src/common/zipstrm.cpp
+++ b/src/common/zipstrm.cpp
@@ -1004,7 +1004,7 @@ size_t wxZipEntry::ReadLocal(wxInputStream& stream, wxMBConv& conv)
 size_t wxZipEntry::WriteLocal(wxOutputStream& stream, wxMBConv& conv) const
 {
     wxString unixName = GetName(wxPATH_UNIX);
-    const wxWX2MBbuf name_buf = conv.cWX2MB(unixName);
+    const wxWX2MBbuf name_buf = unixName.mb_str(conv);
     const char *name = name_buf;
     if (!name) name = "";
     wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name));
@@ -1080,12 +1080,12 @@ size_t wxZipEntry::ReadCentral(wxInputStream& stream, wxMBConv& conv)
 size_t wxZipEntry::WriteCentral(wxOutputStream& stream, wxMBConv& conv) const
 {
     wxString unixName = GetName(wxPATH_UNIX);
-    const wxWX2MBbuf name_buf = conv.cWX2MB(unixName);
+    const wxWX2MBbuf name_buf = unixName.mb_str(conv);
     const char *name = name_buf;
     if (!name) name = "";
     wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name));
 
-    const wxWX2MBbuf comment_buf = conv.cWX2MB(m_Comment);
+    const wxWX2MBbuf comment_buf = m_Comment.mb_str(conv);
     const char *comment = comment_buf;
     if (!comment) comment = "";
     wxUint16 commentLen = wx_truncate_cast(wxUint16, strlen(comment));
@@ -1235,7 +1235,7 @@ wxZipEndRec::wxZipEndRec()
 
 bool wxZipEndRec::Write(wxOutputStream& stream, wxMBConv& conv) const
 {
-    const wxWX2MBbuf comment_buf = conv.cWX2MB(m_Comment);
+    const wxWX2MBbuf comment_buf = m_Comment.mb_str(conv);
     const char *comment = comment_buf;
     if (!comment) comment = "";
     wxUint16 commentLen = (wxUint16)strlen(comment);
diff --git a/src/gtk/animate.cpp b/src/gtk/animate.cpp
index 820536a564..8786f1fde9 100644
--- a/src/gtk/animate.cpp
+++ b/src/gtk/animate.cpp
@@ -82,8 +82,7 @@ wxAnimation& wxAnimation::operator=(const wxAnimation& that)
 bool wxAnimation::LoadFile(const wxString &name, wxAnimationType WXUNUSED(type))
 {
     UnRef();
-    m_pixbuf = gdk_pixbuf_animation_new_from_file(
-        wxConvFileName->cWX2MB(name), NULL);
+    m_pixbuf = gdk_pixbuf_animation_new_from_file(name.fn_str(), NULL);
     return IsOk();
 }
 
diff --git a/src/gtk/dirdlg.cpp b/src/gtk/dirdlg.cpp
index 742961c994..16bd7a83fe 100644
--- a/src/gtk/dirdlg.cpp
+++ b/src/gtk/dirdlg.cpp
@@ -148,7 +148,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title,
 
         if ( !defaultPath.empty() )
             gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
-                    wxConvFileName->cWX2MB(defaultPath) );
+                    defaultPath.fn_str() );
     }
     else
         wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
@@ -192,7 +192,8 @@ void wxDirDialog::SetPath(const wxString& dir)
     {
         if (wxDirExists(dir))
         {
-            gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir));
+            gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+                                                dir.fn_str());
         }
     }
     else
@@ -204,7 +205,7 @@ wxString wxDirDialog::GetPath() const
     if (!gtk_check_version(2,4,0))
     {
         wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
-        return wxConvFileName->cMB2WX(str);
+        return wxString(str, *wxConvFileName);
     }
 
     return wxGenericDirDialog::GetPath();
diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp
index 30395b73f0..1f12180c32 100644
--- a/src/gtk/filedlg.cpp
+++ b/src/gtk/filedlg.cpp
@@ -50,7 +50,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
 
             msg.Printf(
                 _("File '%s' already exists, do you really want to overwrite it?"),
-                wxString(wxConvFileName->cMB2WX(filename)).c_str());
+                wxString(filename, *wxConvFileName));
 
             wxMessageDialog dlg(dialog, msg, _("Confirm"),
                                wxYES_NO | wxICON_QUESTION);
@@ -318,7 +318,7 @@ wxString wxFileDialog::GetPath() const
     if (!gtk_check_version(2,4,0))
     {
         wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
-        return wxConvFileName->cMB2WX(str);
+        return wxString(str, *wxConvFileName);
     }
 
     return wxGenericFileDialog::GetPath();
@@ -350,7 +350,7 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
             GSList *gpaths = gpathsi;
             while (gpathsi)
             {
-                wxString file(wxConvFileName->cMB2WX((gchar*) gpathsi->data));
+                wxString file((gchar*) gpathsi->data, *wxConvFileName);
                 paths.Add(file);
                 g_free(gpathsi->data);
                 gpathsi = gpathsi->next;
@@ -382,7 +382,7 @@ void wxFileDialog::SetPath(const wxString& path)
     {
         if (path.empty()) return;
 
-        gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(path));
+        gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), path.fn_str());
     }
     else
         wxGenericFileDialog::SetPath( path );
@@ -394,7 +394,7 @@ void wxFileDialog::SetDirectory(const wxString& dir)
     {
         if (wxDirExists(dir))
         {
-            gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir));
+            gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), dir.fn_str());
         }
     }
     else
@@ -406,7 +406,7 @@ wxString wxFileDialog::GetDirectory() const
     if (!gtk_check_version(2,4,0))
     {
         wxGtkString str(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_widget)));
-        return wxConvFileName->cMB2WX(str);
+        return wxString(str, *wxConvFileName);
     }
 
     return wxGenericFileDialog::GetDirectory();
diff --git a/src/gtk/hyperlink.cpp b/src/gtk/hyperlink.cpp
index 8d120d9c13..4ea40b70c7 100644
--- a/src/gtk/hyperlink.cpp
+++ b/src/gtk/hyperlink.cpp
@@ -151,7 +151,7 @@ wxString wxHyperlinkCtrl::GetURL() const
     if ( UseNative() )
     {
         const gchar *str = gtk_link_button_get_uri(GTK_LINK_BUTTON(m_widget));
-        return wxConvFileName->cMB2WX(str);
+        return wxString(str, *wxConvFileName);
     }
 
     return wxGenericHyperlinkCtrl::GetURL();
diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp
index bd901c5000..9f80040246 100644
--- a/src/gtk/menu.cpp
+++ b/src/gtk/menu.cpp
@@ -55,14 +55,12 @@ static wxString GetGtkHotKey( const wxMenuItem& item );
 
 static wxString wxReplaceUnderscore( const wxString& title )
 {
-    const wxChar *pc;
-
     // GTK 1.2 wants to have "_" instead of "&" for accelerators
     wxString str;
-    pc = title;
-    while (*pc != wxT('\0'))
+
+    for ( wxString::const_iterator pc = title.begin(); pc != title.end(); ++pc )
     {
-        if ((*pc == wxT('&')) && (*(pc+1) == wxT('&')))
+        if ((*pc == wxT('&')) && (pc+1 != title.end()) && (*(pc+1) == wxT('&')))
         {
             // "&" is doubled to indicate "&" instead of accelerator
             ++pc;
@@ -83,7 +81,6 @@ static wxString wxReplaceUnderscore( const wxString& title )
 
             str << *pc;
         }
-        ++pc;
     }
 
     // wxPrintf( wxT("before %s after %s\n"), title.c_str(), str.c_str() );
diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp
index e5bb933d2b..1dea75490e 100644
--- a/src/gtk/radiobox.cpp
+++ b/src/gtk/radiobox.cpp
@@ -275,7 +275,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
             radio_button_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON(rbtn) );
 
         label.Empty();
-        for ( const wxChar *pc = choices[i]; *pc; pc++ )
+        for ( wxString::const_iterator pc = choices[i].begin();
+              pc != choices[i].end(); ++pc )
         {
             if ( *pc != wxT('&') )
                 label += *pc;
diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp
index c236c47c4e..14bfb8e2b4 100644
--- a/src/msw/utils.cpp
+++ b/src/msw/utils.cpp
@@ -1444,7 +1444,7 @@ extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding)
     return (long) ret;
 }
 
-extern long wxCharsetToCodepage(const wxChar *name)
+extern long wxCharsetToCodepage(const char *name)
 {
     // first get the font encoding for this charset
     if ( !name )
@@ -1463,7 +1463,7 @@ extern long wxCharsetToCodepage(const wxChar *name)
 #include "wx/msw/registry.h"
 
 // this should work if Internet Exploiter is installed
-extern long wxCharsetToCodepage(const wxChar *name)
+extern long wxCharsetToCodepage(const char *name)
 {
     if (!name)
         return GetACP();
diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp
index 76ea00e815..e2371f6497 100644
--- a/src/richtext/richtexthtml.cpp
+++ b/src/richtext/richtexthtml.cpp
@@ -394,7 +394,7 @@ void wxRichTextHTMLHandler::WriteImage(wxRichTextImage* image, wxOutputStream& s
         if (image->GetImage().Ok())
         {        
             wxString ext(image->GetImageBlock().GetExtension());
-            wxString tempFilename(wxString::Format(wxT("image%d.%s"), sm_fileCounter, (const wxChar*) ext));
+            wxString tempFilename(wxString::Format(wxT("image%d.%s"), sm_fileCounter, ext));
             wxMemoryFSHandler::AddFile(tempFilename, image->GetImage(), image->GetImageBlock().GetImageType());
             
             m_imageLocations.Add(tempFilename);
@@ -420,7 +420,7 @@ void wxRichTextHTMLHandler::WriteImage(wxRichTextImage* image, wxOutputStream& s
                 tempDir = wxFileName::GetTempDir();
             
             wxString ext(image->GetImageBlock().GetExtension());
-            wxString tempFilename(wxString::Format(wxT("%s/image%d.%s"), (const wxChar*) tempDir, sm_fileCounter, (const wxChar*) ext));
+            wxString tempFilename(wxString::Format(wxT("%s/image%d.%s"), tempDir, sm_fileCounter, ext));
             image->GetImageBlock().Write(tempFilename);
             
             m_imageLocations.Add(tempFilename);
diff --git a/src/richtext/richtextstyledlg.cpp b/src/richtext/richtextstyledlg.cpp
index 77f034d89b..e31fbc1b03 100644
--- a/src/richtext/richtextstyledlg.cpp
+++ b/src/richtext/richtextstyledlg.cpp
@@ -724,7 +724,7 @@ void wxRichTextStyleOrganiserDialog::OnDeleteClick( wxCommandEvent& WXUNUSED(eve
     {
         wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
         wxString name(def->GetName());
-        if (wxYES == wxMessageBox(wxString::Format(_("Delete style %s?"), (const wxChar*) name), _("Delete Style"), wxYES_NO|wxICON_QUESTION, this))
+        if (wxYES == wxMessageBox(wxString::Format(_("Delete style %s?"), name), _("Delete Style"), wxYES_NO|wxICON_QUESTION, this))
         {
             m_stylesListBox->GetStyleListBox()->SetItemCount(0);
 
diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp
index 2d6df34af1..620f6fd6df 100644
--- a/src/richtext/richtextxml.cpp
+++ b/src/richtext/richtextxml.cpp
@@ -573,7 +573,7 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
 
     wxString s ;
     s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
-        (const wxChar*) version, (const wxChar*) fileEncoding );
+             version, fileEncoding);
     OutputString(stream, s, NULL, NULL);
     OutputString(stream, wxT("<richtext version=\"1.0.0.0\" xmlns=\"http://www.wxwidgets.org\">") , NULL, NULL);
 
diff --git a/src/unix/dir.cpp b/src/unix/dir.cpp
index d87bf47002..7743d9b064 100644
--- a/src/unix/dir.cpp
+++ b/src/unix/dir.cpp
@@ -132,7 +132,7 @@ bool wxDirData::Read(wxString *filename)
             return false;
 
 #if wxUSE_UNICODE
-        de_d_name = wxConvFileName->cMB2WC( de->d_name );
+        de_d_name = wxString(de->d_name, *wxConvFileName);
 #else
         de_d_name = de->d_name;
 #endif
diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp
index 20b96b5c21..4a39baa089 100644
--- a/src/unix/mimetype.cpp
+++ b/src/unix/mimetype.cpp
@@ -1367,14 +1367,15 @@ size_t wxFileTypeImpl::GetAllCommands(wxArrayString *verbs,
 
 bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
 {
-    wxString strExtensions = m_manager->GetExtension(m_index[0]);
+    const wxString strExtensions = m_manager->GetExtension(m_index[0]);
     extensions.Empty();
 
     // one extension in the space or comma-delimited list
     wxString strExt;
-    for ( const wxChar *p = strExtensions; /* nothing */; p++ )
+    wxString::const_iterator end = strExtensions.end();
+    for ( wxString::const_iterator p = strExtensions.begin(); /* nothing */; ++p )
     {
-        if ( *p == wxT(' ') || *p == wxT(',') || *p == wxT('\0') )
+        if ( p == end || *p == wxT(' ') || *p == wxT(',') )
         {
             if ( !strExt.empty() )
             {
@@ -1384,7 +1385,7 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
             //else: repeated spaces
             // (shouldn't happen, but it's not that important if it does happen)
 
-            if ( *p == wxT('\0') )
+            if ( p == end )
                 break;
         }
         else if ( *p == wxT('.') )
@@ -2488,8 +2489,7 @@ wxMimeTypesManagerImpl::ProcessOtherMailcapField(MailcapLineData& data,
     }
 
     // is this something of the form foo=bar?
-    const wxChar *pEq = wxStrchr(curField, wxT('='));
-    if ( pEq != NULL )
+    if ( curField.find('=') != wxString::npos )
     {
         // split "LHS = RHS" in 2
         wxString lhs = curField.BeforeFirst(wxT('=')),
diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp
index 2eab9e451b..25b1558c73 100644
--- a/src/unix/utilsunx.cpp
+++ b/src/unix/utilsunx.cpp
@@ -917,7 +917,8 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
     // get OS version
     int major, minor;
     wxString release = wxGetCommandOutput(wxT("uname -r"));
-    if ( release.empty() || wxSscanf(release, wxT("%d.%d"), &major, &minor) != 2 )
+    if ( release.empty() ||
+         wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 )
     {
         // failed to get version string or unrecognized format
         major =
@@ -1051,7 +1052,7 @@ bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspace
 bool wxGetEnv(const wxString& var, wxString *value)
 {
     // wxGetenv is defined as getenv()
-    wxChar *p = wxGetenv(var);
+    char *p = wxGetenv(var);
     if ( !p )
         return false;
 
diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp
index e9f3e92df7..16ced8c8f6 100644
--- a/src/xml/xml.cpp
+++ b/src/xml/xml.cpp
@@ -558,8 +558,7 @@ static int UnknownEncodingHnd(void * WXUNUSED(encodingHandlerData),
     // We must build conversion table for expat. The easiest way to do so
     // is to let wxCSConv convert as string containing all characters to
     // wide character representation:
-    wxString str(name, wxConvLibc);
-    wxCSConv conv(str.c_str());
+    wxCSConv conv(name);
     char mbBuf[2];
     wchar_t wcBuf[10];
     size_t i;
diff --git a/tests/arrays/arrays.cpp b/tests/arrays/arrays.cpp
index 8d05e0ca8d..f50901de14 100644
--- a/tests/arrays/arrays.cpp
+++ b/tests/arrays/arrays.cpp
@@ -82,7 +82,7 @@ public:
 
    static size_t GetNumber() { return ms_bars; }
 
-   const wxChar *GetName() const { return m_name; }
+   const wxChar *GetName() const { return m_name.c_str(); }
 
 private:
    wxString m_name;
diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp
index db64b5c53e..f2a0d60016 100644
--- a/tests/datetime/datetimetest.cpp
+++ b/tests/datetime/datetimetest.cpp
@@ -639,7 +639,7 @@ void DateTimeTestCase::TestTimeFormat()
 
             // convert back
             wxDateTime dt2;
-            const wxChar *result = dt2.ParseFormat(s, fmt);
+            const wxChar *result = dt2.ParseFormat(s.c_str(), fmt);
             if ( !result )
             {
                 // converion failed - should it have?
diff --git a/tests/formatconverter/formatconvertertest.cpp b/tests/formatconverter/formatconvertertest.cpp
index 987a69e862..b7bcff8873 100644
--- a/tests/formatconverter/formatconvertertest.cpp
+++ b/tests/formatconverter/formatconvertertest.cpp
@@ -286,7 +286,7 @@ void FormatConverterTestCase::doTest(const wxChar *input,
 void FormatConverterTestCase::check(const wxString& input,
                                     const wxString& expected)
 {
-    wxString result = wxConvertFormat(input);
+    wxString result = wxConvertFormat(input.wc_str());
     wxString msg = _T("input: '") + input +
                    _T("', result: '") + result +
                    _T("', expected: '") + expected + _T("'");
diff --git a/tests/lists/lists.cpp b/tests/lists/lists.cpp
index 16ea8a3d37..85eea4c98f 100644
--- a/tests/lists/lists.cpp
+++ b/tests/lists/lists.cpp
@@ -61,7 +61,7 @@ public:
 
    static size_t GetNumber() { return ms_bars; }
 
-   const wxChar *GetName() const { return m_name; }
+   const wxChar *GetName() const { return m_name.c_str(); }
 
 private:
    wxString m_name;
diff --git a/tests/mbconv/mbconvtest.cpp b/tests/mbconv/mbconvtest.cpp
index 49baef19d3..dde306ab6c 100644
--- a/tests/mbconv/mbconvtest.cpp
+++ b/tests/mbconv/mbconvtest.cpp
@@ -120,7 +120,7 @@ private:
         size_t         wideChars,   // the number of wide characters at wideBuffer
         const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
         size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-        wxMBConv*      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
+        wxMBConv&      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
         int            sizeofNull   // number of bytes occupied by terminating null in this encoding
         );
 
@@ -130,7 +130,7 @@ private:
         size_t         wideChars,   // the number of wide characters at wideBuffer
         const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
         size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-        wxMBConv*      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
+        wxMBConv&      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
         int            sizeofNull   // number of bytes occupied by terminating null in this encoding
         );
 
@@ -142,7 +142,7 @@ private:
         size_t         wideChars,   // the number of wide characters at wideBuffer
         const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
         size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-        wxMBConv*      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
+        wxMBConv&      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
         );
 
     // use wxTextOutputStream to exercise wxMBConv interface
@@ -152,7 +152,7 @@ private:
         size_t         wideChars,   // the number of wide characters at wideBuffer
         const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
         size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-        wxMBConv*      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
+        wxMBConv&      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
         );
 #endif
 
@@ -167,7 +167,7 @@ private:
         size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
         const char*    utf8Buffer,  // the same character sequence as multiBuffer, encoded as UTF-8
         size_t         utf8Bytes,   // the byte length of the UTF-8 encoded character sequence
-        wxMBConv*      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
+        wxMBConv&      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
         int            sizeofNull   // the number of bytes occupied by a terminating null in the converter's encoding
         );
 
@@ -393,7 +393,7 @@ void MBConvTestCase::UTF7Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf7_iconv, 
         sizeof(welcome_utf7_iconv), 
-        &wxConvUTF7,
+        wxConvUTF7,
         1
         );
     TestDecoder
@@ -402,7 +402,7 @@ void MBConvTestCase::UTF7Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf7_wx, 
         sizeof(welcome_utf7_wx), 
-        &wxConvUTF7,
+        wxConvUTF7,
         1
         );
 #if 0 
@@ -415,7 +415,7 @@ void MBConvTestCase::UTF7Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf7_iconv, 
         sizeof(welcome_utf7_iconv), 
-        &wxConvUTF7,
+        wxConvUTF7,
         1
         );
 #endif
@@ -425,7 +425,7 @@ void MBConvTestCase::UTF7Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf7_wx, 
         sizeof(welcome_utf7_wx), 
-        &wxConvUTF7,
+        wxConvUTF7,
         1
         );
 }
@@ -438,7 +438,7 @@ void MBConvTestCase::UTF8Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf8, 
         sizeof(welcome_utf8), 
-        &wxConvUTF8,
+        wxConvUTF8,
         1
         );
     TestEncoder
@@ -447,7 +447,7 @@ void MBConvTestCase::UTF8Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf8, 
         sizeof(welcome_utf8), 
-        &wxConvUTF8,
+        wxConvUTF8,
         1
         );
 }
@@ -461,7 +461,7 @@ void MBConvTestCase::UTF16LETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf16le, 
         sizeof(welcome_utf16le), 
-        &convUTF16LE,
+        convUTF16LE,
         2
         );
     TestEncoder
@@ -470,7 +470,7 @@ void MBConvTestCase::UTF16LETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf16le, 
         sizeof(welcome_utf16le), 
-        &convUTF16LE,
+        convUTF16LE,
         2
         );
 }
@@ -484,7 +484,7 @@ void MBConvTestCase::UTF16BETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf16be, 
         sizeof(welcome_utf16be), 
-        &convUTF16BE,
+        convUTF16BE,
         2
         );
     TestEncoder
@@ -493,7 +493,7 @@ void MBConvTestCase::UTF16BETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf16be, 
         sizeof(welcome_utf16be), 
-        &convUTF16BE,
+        convUTF16BE,
         2
         );
 }
@@ -507,7 +507,7 @@ void MBConvTestCase::UTF32LETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf32le, 
         sizeof(welcome_utf32le), 
-        &convUTF32LE,
+        convUTF32LE,
         4
         );
     TestEncoder
@@ -516,7 +516,7 @@ void MBConvTestCase::UTF32LETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf32le, 
         sizeof(welcome_utf32le), 
-        &convUTF32LE,
+        convUTF32LE,
         4
         );
 }
@@ -530,7 +530,7 @@ void MBConvTestCase::UTF32BETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf32be, 
         sizeof(welcome_utf32be), 
-        &convUTF32BE,
+        convUTF32BE,
         4
         );
     TestEncoder
@@ -539,7 +539,7 @@ void MBConvTestCase::UTF32BETests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_utf32be, 
         sizeof(welcome_utf32be), 
-        &convUTF32BE,
+        convUTF32BE,
         4
         );
 }
@@ -553,7 +553,7 @@ void MBConvTestCase::CP932Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_cp932, 
         sizeof(welcome_cp932), 
-        &convCP932,
+        convCP932,
         1
         );
     TestEncoder
@@ -562,7 +562,7 @@ void MBConvTestCase::CP932Tests()
         sizeof(welcome_wchar_t)/sizeof(wchar_t),
         (const char*)welcome_cp932, 
         sizeof(welcome_cp932), 
-        &convCP932,
+        convCP932,
         1
         );
 }
@@ -743,7 +743,7 @@ void MBConvTestCase::TestCoder(
     size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
     const char*    utf8Buffer,  // the same character sequence as multiBuffer, encoded as UTF-8
     size_t         utf8Bytes,   // the byte length of the UTF-8 encoded character sequence
-    wxMBConv*      converter,   // the wxMBConv object thta can decode multiBuffer into a wide character sequence
+    wxMBConv&      converter,   // the wxMBConv object thta can decode multiBuffer into a wide character sequence
     int            sizeofNull   // the number of bytes occupied by a terminating null in the converter's encoding
     )
 {
@@ -777,12 +777,12 @@ void MBConvTestCase::TestCoder(
 }
 
 
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name );
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name );
 
 void MBConvTestCase::FontmapTests()
 {
 #ifdef wxUSE_FONTMAP
-    wxMBConv* converter = new_wxMBConv_wxwin( _T("CP1252") );
+    wxMBConv* converter = new_wxMBConv_wxwin("CP1252");
     if ( !converter )
     {
         return;
@@ -792,7 +792,7 @@ void MBConvTestCase::FontmapTests()
         sizeof(CP1252),
         (const char*)CP1252_utf8,
         sizeof(CP1252_utf8),
-        converter,
+        *converter,
         1
         );
     delete converter;
@@ -800,12 +800,12 @@ void MBConvTestCase::FontmapTests()
 }
 
 
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name );
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name );
 
 void MBConvTestCase::IconvTests()
 {
 #ifdef HAVE_ICONV
-    wxMBConv* converter = new_wxMBConv_iconv( _T("CP932") );
+    wxMBConv* converter = new_wxMBConv_iconv("CP932");
     if ( !converter )
     {
         return;
@@ -815,7 +815,7 @@ void MBConvTestCase::IconvTests()
         sizeof(welcome_cp932),
         (const char*)welcome_utf8,
         sizeof(welcome_utf8),
-        converter,
+        *converter,
         1
         );
     delete converter;
@@ -830,7 +830,7 @@ void MBConvTestCase::CP1252Tests()
         sizeof(CP1252),
         (const char*)CP1252_utf8,
         sizeof(CP1252_utf8),
-        &convCP1252,
+        convCP1252,
         1
         );
 }
@@ -874,7 +874,7 @@ void MBConvTestCase::TestDecoder(
     size_t         wideChars,   // the number of wide characters at wideBuffer
     const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
     size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-    wxMBConv*      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
+    wxMBConv&      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
     int            sizeofNull   // number of bytes occupied by terminating null in this encoding
     )
 {
@@ -886,7 +886,7 @@ void MBConvTestCase::TestDecoder(
     memset( &inputCopy.data()[multiBytes], 0, sizeofNull );
 
     // calculate the output size
-    size_t outputWritten = converter->MB2WC
+    size_t outputWritten = converter.MB2WC
         ( 
         0, 
         (const char*)inputCopy.data(), 
@@ -902,7 +902,7 @@ void MBConvTestCase::TestDecoder(
     wxWCharBuffer outputBuffer(outputBufferChars);
     memset( outputBuffer.data(), UNINITIALIZED, outputBufferChars*sizeof(wchar_t) );
 
-    outputWritten = converter->MB2WC
+    outputWritten = converter.MB2WC
         ( 
         outputBuffer.data(), 
         (const char*)inputCopy.data(), 
@@ -934,7 +934,7 @@ void MBConvTestCase::TestEncoder(
     size_t         wideChars,   // the number of wide characters at wideBuffer
     const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
     size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-    wxMBConv*      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
+    wxMBConv&      converter,   // the wxMBConv object that can decode multiBuffer into a wide character sequence
     int            sizeofNull   // number of bytes occupied by terminating null in this encoding
     )
 {
@@ -946,7 +946,7 @@ void MBConvTestCase::TestEncoder(
     inputCopy.data()[wideChars] = 0;
 
     // calculate the output size
-    size_t outputWritten = converter->WC2MB
+    size_t outputWritten = converter.WC2MB
         ( 
         0, 
         (const wchar_t*)inputCopy.data(), 
@@ -961,7 +961,7 @@ void MBConvTestCase::TestEncoder(
     wxCharBuffer outputBuffer(outputBufferSize);
     memset( outputBuffer.data(), UNINITIALIZED, outputBufferSize );
 
-    outputWritten = converter->WC2MB
+    outputWritten = converter.WC2MB
         ( 
         outputBuffer.data(), 
         (const wchar_t*)inputCopy.data(), 
@@ -1001,14 +1001,14 @@ void MBConvTestCase::TestStreamDecoder(
                                        size_t         wideChars,   // the number of wide characters at wideBuffer
                                        const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
                                        size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-                                       wxMBConv*      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
+                                       wxMBConv&      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
                                        )
 {
     // this isn't meant to test wxMemoryInputStream or wxTextInputStream
     // it's meant to test the way wxTextInputStream uses wxMBConv
     // (which has exposed some problems with wxMBConv)
     wxMemoryInputStream memoryInputStream( multiBuffer, multiBytes );
-    wxTextInputStream textInputStream( memoryInputStream, wxT(""), *converter );
+    wxTextInputStream textInputStream( memoryInputStream, wxT(""), converter );
     for ( size_t i = 0; i < wideChars; i++ )
     {
         wxChar wc = textInputStream.GetChar();
@@ -1027,7 +1027,7 @@ void MBConvTestCase::TestStreamEncoder(
     size_t         wideChars,   // the number of wide characters at wideBuffer
     const char*    multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
     size_t         multiBytes,  // the byte length of the multibyte character sequence that can be decoded by "converter"
-    wxMBConv*      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
+    wxMBConv&      converter    // the wxMBConv object that can decode multiBuffer into a wide character sequence
     )
 {
     // this isn't meant to test wxMemoryOutputStream or wxTextOutputStream
@@ -1035,7 +1035,7 @@ void MBConvTestCase::TestStreamEncoder(
     // (which has exposed some problems with wxMBConv)
     wxMemoryOutputStream memoryOutputStream;
     // wxEOL_UNIX will pass \n \r unchanged
-    wxTextOutputStream textOutputStream( memoryOutputStream, wxEOL_UNIX, *converter );
+    wxTextOutputStream textOutputStream( memoryOutputStream, wxEOL_UNIX, converter );
     for ( size_t i = 0; i < wideChars; i++ )
     {
         textOutputStream.PutChar( wideBuffer[i] );
diff --git a/tests/regex/regextest.cpp b/tests/regex/regextest.cpp
index 8988557568..ef63306560 100644
--- a/tests/regex/regextest.cpp
+++ b/tests/regex/regextest.cpp
@@ -178,8 +178,9 @@ wxString RegExTestCase::Conv(const char *str)
 //
 void RegExTestCase::parseFlags(const wxString& flags)
 {
-    for (const wxChar *p = flags; *p; p++) {
-        switch (*p) {
+    for ( wxString::const_iterator p = flags.begin(); p != flags.end(); ++p )
+    {
+        switch ( (*p).GetValue() ) {
             // noop
             case '-': break;
 
-- 
2.47.2