{$CODEPAGE UTF8}
uses
  dutf8;

const
  S1: PAnsiChar = #$d1#$8f; // 'я'
  S2: PAnsiChar = #$78#$d1#$8f#$78; // 'xяx'
  S3: PAnsiChar = #$78#$d1#$8e#$d1#$8f#$78; // 'x?яx'

var
  Pos: PAnsiChar;

procedure Test(S: PAnsiChar);
begin
  Writeln(ScanUTF8(S, S + Length(S), 1103, Pos), ' ', Pos - S);
end;

begin
  Test(S1);
  Test(S2);
  Test(S3);
end.
