After the answer to my question, I removed {$mode DelphiUnicode} everywhere and I still use String everywhere. As I got, String means AnsiString if {$mode DelphiUnicode} is not used.
And I have a code:
Var
CmdLineArgs: CommandLine.Args;
infile: Text;
line: String;
output: Boolean = True;
Begin
CommandLine.Parse(self, CmdLineArgs);
WriteLn(CmdLineArgs.InputFile);
AssignFile(infile, CmdLineArgs.InputFile);
Try
Reset(infile);
While Not EOF(infile) Do
Begin
ReadLn(infile, line);
If output Then WriteLn(line, ' ', Length(line));
End;
Finally
CloseFile(infile);
End;
The passed via command line options file is UTF-8. And I see that Length(line) returns everytime 2x length to the real symbols number. But if I turn on the {$mode DelphiUnicode}, then it shows the correct length (as I said, I turned off it because of this). It means that AnsiString's Length returns bytes number, not codepoints number. So, the question now is: what is the correct pragmatic and modern way to work with national languages (in files, in constants, everywhere) in FPC - I prefer UTF8 encoding? I am with 3.2.2 version.
EDIT:
Args is just an object with a processed file path:
Type
Args = Object
InputFile: String;
End;