--- codecvt_null.cpp.original 2003-11-01 08:41:00.000000000 +0300 +++ codecvt_null.cpp 2003-11-04 10:19:48.000000000 +0300 @@ -28,7 +28,10 @@ char * & next2 ) const { for(;first1 != last1; ++first1){ - if(sizeof(wchar_t) >= (last2 - first2)){ + // Per std::22.2.1.5.2/2, we can store no more that + // last2-first2 characters. If we need to more encode + // next internal char type, return 'partial'. + if(sizeof(wchar_t) > (last2 - first2)){ next1 = first1; next2 = first2; return std::codecvt_base::partial; @@ -52,7 +55,17 @@ wchar_t * last2, wchar_t * & next2 ) const { + // Process input characters until we've run of them, + // or the number of remaining characters is not + // enough to construct another output character, + // or we've run out of place for output characters. while(first2 != last2){ + // Have we converted all input characters? + // Return with 'ok', if so. + if (first1 == last1) + break; + // Do we have less input characters than needed + // for a single output character? if(sizeof(wchar_t) > (last1 - first1)){ next1 = first1; next2 = first2;