anchor.diff:      if AChar.Length = 4 then AChar.Char[3] := APos[3];
   
       Inc(APos, AChar.Length);
  -    ANewPos^ := APos;
     end;
   
   var
  -  c: PAnsiChar;
  +  c, nc: PAnsiChar;
  +  i: Integer;
     LChar: TUTF8Char;
     LValueIdx: Integer = -1;
     LValues: array[0..MAX_VALUES-1] of utf8string; // for now only 2 values for set
  
positive.code: type
    TToken = (tkNone, tkPercent, tkLess, tkGreater, tkEqual, tkLessOrEqual,
      tkGreaterOrEqual, tkOpeningParenthesis, tkClosingParenthesis,
      tkOpeningBracket, tkClosingBracket,  tkText, tkNum, tkWhiteChar);
  
    TUTF8Char = record
      Length: byte;
      Char: array [0..3] of AnsiChar;
    end;
  
    procedure GetChar(APos: PAnsiChar; out AChar: TUTF8Char; ANewPos: PPAnsiChar);
    begin
      AChar.Length := UTF8CharacterLength(APos);
  
  
negative.code:           tkNone:
              AExpressionRecord.TextMatchKind:=tmkMatchTextBeginning;
          end;
        tkLess..tkGreaterOrEqual:
          if LPrevToken <> tkNone then
            raise Exception.Create('Bad numeric expression')
          else
            with AExpressionRecord do
            case LToken of
              tkLess: NumericComparisionKind:=nckNumericLT;
              tkGreater: NumericComparisionKind:=nckNumericGT;
              tkEqual: NumericComparisionKind:=nckNumericEQ;
              tkLessOrEqual: NumericComparisionKind:=nckNumericLTE;
              tkGreaterOrEqual: NumericComparisionKind:=nckNumericGTE;
            end;
        tkOpeningParenthesis, tkOpeningBracket:
          if LPrevToken <> tkNone then
            raise Exception.Create('Bad "between" expression')
          else
          with AExpressionRecord do
          case LToken of
            tkOpeningParenthesis: SetKind:=skNumericBetweenExclusive;
            tkOpeningBracket: SetKind:=skNumericBetweenInclusive;
          end;
      end;
      LPrevToken := LToken;
      Inc(c);
    until (LChar.Length=0) or (c^ = #0);
  
    case AExpressionKind of
      ekText:
        if AExpressionRecord.TextMatchKind = tmkUnknown then
          AExpressionRecord.TextMatchKind:=tmkMatchTextExact;
      ekSet:
        case AExpressionRecord.SetKind of
          skNumericBetweenInclusive:
            if LPrevToken <> tkClosingBracket then
              raise Exception.Create('Badly closed "between" expression');
          skNumericBetweenExclusive:
            if LPrevToken <> tkClosingParenthesis then
              raise Exception.Create('Badly closed "between" expression');
        end;
    end;
  
    if LValueIdx = -1 then
      raise Exception.Create('Expression have not a value');
  
    SetLength(AExpressionRecord.Values, LValueIdx + 1);
    for i := 0 to LValueIdx do
      AExpressionRecord.Values[i] := LValues[i];
  
    AExpressionRecord.Kind := AExpressionKind;
  end;
  