--- parser3/src/main/pa_string.C 2009/06/23 10:05:16 1.229 +++ parser3/src/main/pa_string.C 2009/07/08 10:07:45 1.231 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_STRING_C="$Date: 2009/06/23 10:05:16 $"; +static const char * const IDENT_STRING_C="$Date: 2009/07/08 10:07:45 $"; #include "pa_string.h" #include "pa_exception.h" @@ -226,7 +226,8 @@ String::Body String::Body::trim(String:: while(src_begin127 && *src_begin<0xC0)/* searching first UTF-8 byte */) + // searching first UTF-8 byte: http://tools.ietf.org/html/rfc3629#section-3 + while(++src_begin<=src_end && (*src_begin>127 && *src_begin<0xC0)) char_length++; bool found=false; @@ -249,7 +250,8 @@ String::Body String::Body::trim(String:: if(kind!=TRIM_START) { while(src_begin127 && *src_end<0xC0)/* searching first UTF-8 byte */) + // searching first UTF-8 byte: http://tools.ietf.org/html/rfc3629#section-3 + while(src_begin<=--src_end && (*src_end>127 && *src_end<0xC0)) char_length++; bool found=false; @@ -407,12 +409,12 @@ String& String::mid(Charset& charset, si return result; if(charset.isUTF8()){ - const XMLByte* srcPtr=(const XMLByte*)cstrm(); - const XMLByte* srcEnd=srcPtr+body.length(); + const XMLByte* src_begin=(const XMLByte*)cstrm(); + const XMLByte* src_end=src_begin+body.length(); // convert 'from' and 'substr_length' from 'characters' to 'bytes' - from=getUTF8BytePos(srcPtr, srcEnd, from); - substr_length=getUTF8BytePos(srcPtr+from, srcEnd, substr_length); + from=getUTF8BytePos(src_begin, src_end, from); + substr_length=getUTF8BytePos(src_begin+from, src_end, substr_length); if(!substr_length) return result; }