--- code_converter.hpp.orig	Sat Mar 22 22:45:55 2008
+++ code_converter.hpp	Wed Jul  9 14:02:46 2008
@@ -331,8 +346,10 @@
         case std::codecvt_base::noconv:
             {
                 std::streamsize amt = 
-                    std::min<std::streamsize>(next - buf.ptr(), n - total);
+                    std::min<std::streamsize>(buf.eptr() - buf.ptr(),
+                                               n - total);
                 detail::strncpy_if_same(s + total, buf.ptr(), amt);
+                buf.ptr() += amt;
                 total += amt;
             }
             break;
@@ -383,9 +400,10 @@
         case std::codecvt_base::noconv:
             {
                 std::streamsize amt = 
-                    std::min<std::streamsize>( nint - total - s, 
-                                               buf.end() - buf.eptr() );
+                    std::min<std::streamsize>(n - total,
+                                               buf.end() - buf.eptr());
                 detail::strncpy_if_same(buf.eptr(), s + total, amt);
+                buf.eptr() += amt;
                 total += amt;
             }
             break;
--- detail/codecvt_holder.hpp.orig	Sat Mar 22 22:45:55 2008
+++ detail/codecvt_holder.hpp	Wed Jul  9 15:06:19 2008
@@ -21,8 +21,8 @@
 
 namespace boost { namespace iostreams { namespace detail {
 
-struct default_codecvt { 
-    typedef wchar_t         intern_type, from_type;
+template <class C> struct basic_default_codecvt { 
+    typedef C                intern_type, from_type;
     typedef char            extern_type, to_type;
     typedef std::mbstate_t  state_type;
 };
@@ -35,9 +35,9 @@
     Codecvt codecvt_;
 };
 
-template<>
-struct codecvt_holder<default_codecvt> {
-    typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
+template<typename C>
+struct codecvt_holder<basic_default_codecvt<C> > {
+    typedef std::codecvt<C, char, std::mbstate_t> codecvt_type;
     codecvt_holder() { reset_codecvt(); }
     const codecvt_type& get() const { return *codecvt_; }
     void imbue(const std::locale& loc) 
@@ -57,6 +57,8 @@
     std::locale loc_; // Prevent codecvt_ from being freed.
     const codecvt_type* codecvt_;
 };
+
+typedef basic_default_codecvt<wchar_t> default_codecvt;
 
 } } } // End namespaces detail, iostreams, boost.
 
