String is an alias for ShortString, AnsiString or Unicodestring (UTF16) depending on a compiler setting.
If compiler directive {$H} or compiler directive {$LongStrings} has been used with an "on" parameter ( {$H+} or {$LongStrings ON} ), then a String type is the same as an AnsiString type, if not ( {$H-} or {$LongStrings OFF} ), it is a ShortString type. What String is an alias for can also be set by the -Sh command line option. FPC also supports {$mode delphiunicode} for Delphi compatible UTF16 support.
NOTE: The {$mode} compiler directive will also set the String alias. After the compiler mode is set to FPC (the default), ObjFPC, MacPAS or TP, String will be an alias for ShortString. After the compiler mode is set to Delphi, String will be an alias for AnsiString. So the String alias setting should be made following the compiler mode setting to prevent it from being overridden:
{$H+} // String is an alias for AnsiString
{$mode ObjFPC} // also affects String alias - String is now an alias for ShortString
{$H+} // String is now an alias for AnsiString
A String variable declared with a length specifier will always be a ShortString regardless of the compiler setting for String alias.
https://wiki.freepascal.org/String