anchor.diff:   EndBytePos: PChar;
    MaxBytes: PtrInt;
   begin
  - StartBytePos:=UTF8CharStart(PChar(s),length(s),StartCharIndex-1);
  - if StartBytePos=nil then
  -   Result:=''
  + StartBytePos := UTF8CharStart(PChar(s),length(s),StartCharIndex-1);
  + if StartBytePos = nil then
  +   Result := ''
    else
    begin
  -   MaxBytes:=PtrInt(PChar(s)+length(s)-StartBytePos);
  -   EndBytePos:=UTF8CharStart(StartBytePos,MaxBytes,CharCount);
  -   if EndBytePos=nil then
  -     Result:=copy(s,StartBytePos-PChar(s)+1,MaxBytes)
  +   MaxBytes := PtrInt(PChar(s)+length(s)-StartBytePos);
  +   EndBytePos := UTF8CharStart(StartBytePos,MaxBytes,CharCount);
  +   if EndBytePos = nil then
  +     Result := copy(s,StartBytePos-PChar(s)+1,MaxBytes)
      else
  -     Result:=copy(s,StartBytePos-PChar(s)+1,EndBytePos-StartBytePos);
  +     Result := copy(s,StartBytePos-PChar(s)+1,EndBytePos-StartBytePos);
    end;
   end;
   
  
positive.code: var
    CharLen: LongInt;
  begin
    Result:=0;
    while (ByteCount>0) do
    begin
      inc(Result);
      CharLen:=UTF8CharacterLength(p);
      inc(p,CharLen);
      dec(ByteCount,CharLen);
    end;
  end;
  
  
negative.code:     begin
        // could be 2 byte character
        if (ord(p[1]) and %11000000) = %10000000 then
          Result := 2
        else
          Result := 1;
      end
      else if ((ord(p^) and %11110000) = %11100000) then
      begin
  