Browse Source

* Char -> AnsiChar

Michael VAN CANNEYT 2 years ago
parent
commit
d2d3fe6bc3

+ 14 - 14
rtl/inc/astrings.inc

@@ -23,15 +23,15 @@
 {
   This file contains the implementation of the AnsiString type,
   and all things that are needed for it.
-  AnsiString is defined as a 'silent' pchar :
-  a pchar that points to (S= SizeOf(SizeInt), R= (if CPU64 then SizeOf(Longint) else SizeOf(SizeInt))):
+  AnsiString is defined as a 'silent' pansichar :
+  a pansichar that points to (S= SizeOf(SizeInt), R= (if CPU64 then SizeOf(Longint) else SizeOf(SizeInt))):
 
   @-S-R-4 : Code page indicator.
   @-S-R-2 : Character size (2 bytes)
   @-S-R   : Reference count (R bytes)
   @-S  : SizeInt for size;
   @    : String + Terminating #0;
-  Pchar(Ansistring) is a valid typecast.
+  PAnsiChar(Ansistring) is a valid typecast.
   So AS[i] is converted to the address @AS+i-1.
 
   Constants should be assigned a reference count of -1
@@ -83,7 +83,7 @@ end;
 
 {$ifndef FPC_HAS_PCHAR_ANSISTR_INTERN_CHARMOVE}
 {$define FPC_HAS_PCHAR_ANSISTR_INTERN_CHARMOVE}
-procedure fpc_pchar_ansistr_intern_charmove(const src: pchar; const srcindex: sizeint; var dst: rawbytestring; const dstindex, len: sizeint); {$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif} {$ifdef SYSTEMINLINE}inline;{$endif}
+procedure fpc_pchar_ansistr_intern_charmove(const src: pansichar; const srcindex: sizeint; var dst: rawbytestring; const dstindex, len: sizeint); {$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif} {$ifdef SYSTEMINLINE}inline;{$endif}
 begin
   move(src[srcindex],pbyte(pointer(dst))[dstindex],len);
 end;
@@ -92,7 +92,7 @@ end;
 
 {$ifndef FPC_HAS_PCHAR_PCHAR_INTERN_CHARMOVE}
 {$define FPC_HAS_PCHAR_PCHAR_INTERN_CHARMOVE}
-procedure fpc_pchar_pchar_intern_charmove(const src: pchar; const srcindex: sizeint; const dst: pchar; const dstindex, len: sizeint); {$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif} {$ifdef SYSTEMINLINE}inline;{$endif}
+procedure fpc_pchar_pchar_intern_charmove(const src: pansichar; const srcindex: sizeint; const dst: pansichar; const dstindex, len: sizeint); {$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif} {$ifdef SYSTEMINLINE}inline;{$endif}
 begin
   move(src[srcindex],dst[dstindex],len);
 end;
@@ -120,7 +120,7 @@ Var
   P : Pointer;
 begin
   { request a multiple of 16 because the heap manager alloctes anyways chunks of 16 bytes }
-  GetMem(P,Len+(AnsiFirstOff+sizeof(char)));
+  GetMem(P,Len+(AnsiFirstOff+sizeof(AnsiChar)));
   If P<>Nil then
    begin
      PAnsiRec(P)^.Ref:=1;         { Set reference count }
@@ -533,7 +533,7 @@ end;
 {$define FPC_HAS_CHAR_TO_ANSISTR}
 Function fpc_Char_To_AnsiStr(const c : AnsiChar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
 {
-  Converts a Char to a AnsiString;
+  Converts a AnsiChar to a AnsiString;
 }
 {$ifndef FPC_HAS_CPSTRING}
 var
@@ -1001,9 +1001,9 @@ end;
 
 {$ifndef FPC_HAS_POS_ANSICHAR_ANSISTR}
 {$define FPC_HAS_POS_ANSICHAR_ANSISTR}
-{ Faster version for a char alone. Must be implemented because   }
-{ pos(c: char; const s: shortstring) also exists, so otherwise   }
-{ using pos(char,pchar) will always call the shortstring version }
+{ Faster version for a AnsiChar alone. Must be implemented because   }
+{ pos(c: AnsiChar; const s: shortstring) also exists, so otherwise   }
+{ using pos(AnsiChar,pansichar) will always call the shortstring version }
 { (exact match for first argument), also with $h+ (JM)           }
 Function Pos(c : AnsiChar; Const s : RawByteString; Offset : Sizeint = 1) : SizeInt;
 var
@@ -1383,7 +1383,7 @@ begin
   If (Size<=LS-Index) then
     begin
       Dec(Index);
-      fpc_pchar_ansistr_intern_charmove(pchar(S),Index+Size,S,Index,LS-Index-Size+1);
+      fpc_pchar_ansistr_intern_charmove(PAnsiChar(S),Index+Size,S,Index,LS-Index-Size+1);
     end;
   Setlength(S,LS-Size);
 end;
@@ -1410,10 +1410,10 @@ begin
     cp:=TranslatePlaceholderCP(StringCodePage(Source));
   SetCodePage(Temp,cp,false);
   If Index>0 then
-    fpc_pchar_ansistr_intern_charmove(pchar(S),0,Temp,0,Index);
-  fpc_pchar_ansistr_intern_charmove(pchar(Source),0,Temp,Index,Length(Source));
+    fpc_pchar_ansistr_intern_charmove(PAnsiChar(S),0,Temp,0,Index);
+  fpc_pchar_ansistr_intern_charmove(PAnsiChar(Source),0,Temp,Index,Length(Source));
   If (LS-Index)>0 then
-    fpc_pchar_ansistr_intern_charmove(pchar(S),Index,Temp,Length(Source)+Index,LS-Index);
+    fpc_pchar_ansistr_intern_charmove(PAnsiChar(S),Index,Temp,Length(Source)+Index,LS-Index);
   S:=Temp;
 end;
 

+ 2 - 2
rtl/inc/blockrtl.pp

@@ -86,7 +86,7 @@ interface
       { signatures are only for the "ABI.2010.3.16" version, but that's all we support
         because otherwise the callback has to be a C-style variadic function, which
         we cannot (yet?) generate on the callee side}
-      signature: pchar;
+      signature: pAnsichar;
     end;
 
     { descriptor for a simple block (no copy/release) }
@@ -98,7 +98,7 @@ interface
       { signatures are only for the "ABI.2010.3.16" version, but that's all we support
         because otherwise the callback has to be a C-style variadic function, which
         we cannot (yet?) generate on the callee side}
-      signature: pchar;
+      signature: pansichar;
     end;
 
     { for global procedures }

+ 2 - 2
rtl/inc/cgeneric.inc

@@ -120,9 +120,9 @@ end;
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
-function libc_pchar_length(p:pchar):size_t; cdecl; external clib name 'strlen';
+function libc_pchar_length(p:PAnsiChar):size_t; cdecl; external clib name 'strlen';
 
-function fpc_pchar_length(p:pchar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
+function fpc_pchar_length(p:PAnsiChar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
 begin
   if assigned(p) then
     fpc_pchar_length:=libc_pchar_length(p)

+ 19 - 19
rtl/inc/cgenstr.inc

@@ -19,7 +19,7 @@
 {$ifndef FPC_UNIT_HAS_STREND}
 {$define FPC_UNIT_HAS_STREND}
 
- function StrEnd(P: PChar): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
+ function StrEnd(P: PAnsiChar): PAnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
    begin
      strend := p+strlen(p);
    end;
@@ -28,9 +28,9 @@
 
 {$ifndef FPC_UNIT_HAS_STRCOPY}
 {$define FPC_UNIT_HAS_STRCOPY}
- function libc_strcpy(dest: pchar; const src: pchar): pchar; cdecl; external 'c' name 'strcpy';
+ function libc_strcpy(dest: pansichar; const src: pansichar): pansichar; cdecl; external 'c' name 'strcpy';
 
- Function StrCopy(Dest, Source:PChar): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
+ Function StrCopy(Dest, Source:PAnsiChar): PAnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      StrCopy := libc_strcpy(dest,source);
    end;
@@ -39,9 +39,9 @@
 
 {$ifndef FPC_UNIT_HAS_STRSCAN}
 {$define FPC_UNIT_HAS_STRSCAN}
- function libc_strchr(const p: pchar; c: longint): pchar; cdecl; external 'c' name 'strchr';
+ function libc_strchr(const p: PAnsiChar; c: longint): PAnsiChar; cdecl; external 'c' name 'strchr';
 
- function StrScan(P: PChar; C: Char): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
+ function StrScan(P: PAnsiChar; C: AnsiChar): PAnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      StrScan := libc_strchr(p,longint(c));
    end;
@@ -50,9 +50,9 @@
 
 {$ifndef FPC_UNIT_HAS_STRRSCAN}
 {$define FPC_UNIT_HAS_STRRSCAN}
- function libc_strrchr(const p: pchar; c: longint): pchar; cdecl; external 'c' name 'strrchr';
+ function libc_strrchr(const p: PAnsiChar; c: longint): PAnsiChar; cdecl; external 'c' name 'strrchr';
 
- function StrRScan(P: PChar; C: Char): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
+ function StrRScan(P: PAnsiChar; C: AnsiChar): PAnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      StrRScan := libc_strrchr(p,longint(c));
    end;
@@ -61,9 +61,9 @@
 (*
 {$ifndef FPC_UNIT_HAS_STRECOPY}
 {$define FPC_UNIT_HAS_STRECOPY}
- function libc_stpcpy(dest: pchar; const src: pchar): pchar; cdecl; external 'c' name 'stpcpy';
+ function libc_stpcpy(dest: PAnsiChar; const src: PAnsiChar): PAnsiChar; cdecl; external 'c' name 'stpcpy';
 
-  Function StrECopy(Dest, Source: PChar): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
+  Function StrECopy(Dest, Source: PAnsiChar): PAnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
     Begin
       StrECopy := libc_stpcpy(dest,source);
     end;
@@ -74,9 +74,9 @@
 {$ifndef FPC_UNIT_HAS_STRLCOPY}
 {$define FPC_UNIT_HAS_STRLCOPY}
 
- function libc_strlcpy(dest: pchar; const src: pchar; maxlen: SizeInt): SizeInt; cdecl; external 'c' name 'strlcpy';
+ function libc_strlcpy(dest: PAnsiChar; const src: PAnsiChar; maxlen: SizeInt): SizeInt; cdecl; external 'c' name 'strlcpy';
 
- Function StrLCopy(Dest,Source: PChar; MaxLen: SizeInt): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
+ Function StrLCopy(Dest,Source: PAnsiChar; MaxLen: SizeInt): PAnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      libc_strlcpy(dest,source,maxlen);
      StrLCopy := Dest;
@@ -86,9 +86,9 @@
 
 {$ifndef FPC_UNIT_HAS_STRCOMP}
 {$define FPC_UNIT_HAS_STRCOMP}
- function libc_strcmp(const str1,str2: pchar): longint; cdecl; external 'c' name 'strcmp';
+ function libc_strcmp(const str1,str2: PAnsiChar): longint; cdecl; external 'c' name 'strcmp';
 
- function StrComp(Str1, Str2 : PChar): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+ function StrComp(Str1, Str2 : PAnsiChar): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      strcomp := libc_strcmp(str1,str2);
    end;
@@ -97,9 +97,9 @@
 
 {$ifndef FPC_UNIT_HAS_STRICOMP}
 {$define FPC_UNIT_HAS_STRICOMP}
- function libc_strcasecmp(const str1,str2: pchar): longint; cdecl; external 'c' name 'strcasecmp';
+ function libc_strcasecmp(const str1,str2: PAnsiChar): longint; cdecl; external 'c' name 'strcasecmp';
 
- function StrIComp(Str1, Str2 : PChar): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+ function StrIComp(Str1, Str2 : PAnsiChar): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      stricomp := libc_strcasecmp(str1,str2);
    end;
@@ -108,9 +108,9 @@
 
 {$ifndef FPC_UNIT_HAS_STRLCOMP}
 {$define FPC_UNIT_HAS_STRLCOMP}
- function libc_strncmp(const str1,str2: pchar; l: sizeint): longint; cdecl; external 'c' name 'strncmp';
+ function libc_strncmp(const str1,str2: PAnsiChar; l: sizeint): longint; cdecl; external 'c' name 'strncmp';
 
- function StrLComp(Str1, Str2 : PChar; L: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+ function StrLComp(Str1, Str2 : PAnsiChar; L: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      strlcomp := libc_strncmp(str1,str2,l);
    end;
@@ -119,9 +119,9 @@
 
 {$ifndef FPC_UNIT_HAS_STRLICOMP}
 {$define FPC_UNIT_HAS_STRLICOMP}
- function libc_strncasecmp(const str1,str2: pchar; l: sizeint): longint; cdecl; external 'c' name 'strncasecmp';
+ function libc_strncasecmp(const str1,str2: PAnsiChar; l: sizeint): longint; cdecl; external 'c' name 'strncasecmp';
 
- function StrLIComp(Str1, Str2 : PChar; L: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+ function StrLIComp(Str1, Str2 : PAnsiChar; L: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
    Begin
      strlicomp := libc_strncasecmp(str1,str2,l);
    end;

+ 2 - 2
rtl/inc/charset.pp

@@ -77,7 +77,7 @@ unit charset;
     function getmap(cp : word) : punicodemap;
     function mappingavailable(const s : string) : boolean;inline;
     function mappingavailable(cp :word) : boolean;inline;
-    function getunicode(c : char;p : punicodemap) : tunicodechar;inline;
+    function getunicode(c : AnsiChar;p : punicodemap) : tunicodechar;inline;
     function getunicode(
       AAnsiStr : pansichar;
       AAnsiLen : LongInt;
@@ -609,7 +609,7 @@ unit charset;
          mappingavailable:=getmap(cp)<>nil;
       end;
 
-    function getunicode(c : char;p : punicodemap) : tunicodechar;
+    function getunicode(c : AnsiChar;p : punicodemap) : tunicodechar;
 
       begin
          if ord(c)<=p^.lastchar then

+ 42 - 42
rtl/inc/compproc.inc

@@ -50,20 +50,20 @@ procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring);
 function fpc_shortstr_compare(const left,right:shortstring) : longint; compilerproc;
 function fpc_shortstr_compare_equal(const left,right:shortstring) : longint; compilerproc;
 
-procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar); compilerproc;
+procedure fpc_pchar_to_shortstr(out res : shortstring;p:PAnsiChar); compilerproc;
 
-function fpc_pchar_length(p:pchar):sizeint; compilerproc;
+function fpc_pchar_length(p:PAnsiChar):sizeint; compilerproc;
 function fpc_pwidechar_length(p:pwidechar):sizeint; compilerproc;
 
-procedure fpc_chararray_to_shortstr(out res : shortstring;const arr: array of char; zerobased: boolean = true); compilerproc;
-procedure fpc_shortstr_to_chararray(out res: array of char; const src: ShortString); compilerproc;
+procedure fpc_chararray_to_shortstr(out res : shortstring;const arr: array of AnsiChar; zerobased: boolean = true); compilerproc;
+procedure fpc_shortstr_to_chararray(out res: array of AnsiChar; const src: ShortString); compilerproc;
 
 Function  fpc_shortstr_Copy(const s:shortstring;index:SizeInt;count:SizeInt):shortstring;compilerproc{$ifndef VER3_0}:fpc_in_copy_x{$endif VER3_0};
-function  fpc_char_copy(c:char;index : SizeInt;count : SizeInt): shortstring;compilerproc{$ifndef VER3_0}:fpc_in_copy_x{$endif VER3_0};
+function  fpc_char_copy(c:AnsiChar;index : SizeInt;count : SizeInt): shortstring;compilerproc{$ifndef VER3_0}:fpc_in_copy_x{$endif VER3_0};
 {$ifndef VER3_0}
 Procedure fpc_shortstr_delete(var s:shortstring;index:SizeInt;count:SizeInt); compilerproc:fpc_in_delete_x_y_z;
 Procedure fpc_shortstr_insert(const source:shortstring;var s:shortstring;index:SizeInt); compilerproc:fpc_in_insert_x_y_z;
-Procedure fpc_shortstr_insert_char(source:Char;var s:shortstring;index:SizeInt); compilerproc:fpc_in_insert_x_y_z;
+Procedure fpc_shortstr_insert_char(source:AnsiChar;var s:shortstring;index:SizeInt); compilerproc:fpc_in_insert_x_y_z;
 {$endif VER3_0}
 
 {$ifdef FPC_HAS_FEATURE_DYNARRAYS}
@@ -102,8 +102,8 @@ procedure fpc_shortstr_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out
 procedure fpc_shortstr_bool(b : boolean;len:sizeint;out s:shortstring);compilerproc;
 procedure fpc_ShortStr_Currency(c : currency; len,f : SizeInt; out s : shortstring); compilerproc;
 
-procedure fpc_chararray_sint(v : valsint;len : SizeInt;out a : array of char); compilerproc;
-procedure fpc_chararray_uint(v : valuint;len : SizeInt;out a : array of char); compilerproc;
+procedure fpc_chararray_sint(v : valsint;len : SizeInt;out a : array of AnsiChar); compilerproc;
+procedure fpc_chararray_uint(v : valuint;len : SizeInt;out a : array of AnsiChar); compilerproc;
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 procedure fpc_AnsiStr_sint(v : valsint; Len : SizeInt; out S : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
 procedure fpc_AnsiStr_uint(v : valuint;Len : SizeInt; out S : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
@@ -127,8 +127,8 @@ procedure fpc_AnsiStr_Currency(c : currency;len,fr : SizeInt;out s : RawByteStri
 {$ifndef CPU64}
   procedure fpc_shortstr_qword(v : qword;len : SizeInt;out s : shortstring); compilerproc;
   procedure fpc_shortstr_int64(v : int64;len : SizeInt;out s : shortstring); compilerproc;
-  procedure fpc_chararray_qword(v : qword;len : SizeInt;out a : array of char); compilerproc;
-  procedure fpc_chararray_int64(v : int64;len : SizeInt;out a : array of char); compilerproc;
+  procedure fpc_chararray_qword(v : qword;len : SizeInt;out a : array of AnsiChar); compilerproc;
+  procedure fpc_chararray_int64(v : int64;len : SizeInt;out a : array of AnsiChar); compilerproc;
   {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
   procedure fpc_ansistr_qword(v : qword;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
   procedure fpc_ansistr_int64(v : int64;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
@@ -146,8 +146,8 @@ procedure fpc_AnsiStr_Currency(c : currency;len,fr : SizeInt;out s : RawByteStri
 {$if defined(CPU16) or defined(CPU8)}
   procedure fpc_shortstr_longword(v : longword;len : SizeInt;out s : shortstring); compilerproc;
   procedure fpc_shortstr_longint(v : longint;len : SizeInt;out s : shortstring); compilerproc;
-  procedure fpc_chararray_longword(v : longword;len : SizeInt;out a : array of char); compilerproc;
-  procedure fpc_chararray_longint(v : longint;len : SizeInt;out a : array of char); compilerproc;
+  procedure fpc_chararray_longword(v : longword;len : SizeInt;out a : array of AnsiChar); compilerproc;
+  procedure fpc_chararray_longint(v : longint;len : SizeInt;out a : array of AnsiChar); compilerproc;
   {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
   procedure fpc_ansistr_longword(v : longword;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
   procedure fpc_ansistr_longint(v : longint;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
@@ -164,8 +164,8 @@ procedure fpc_AnsiStr_Currency(c : currency;len,fr : SizeInt;out s : RawByteStri
 
   procedure fpc_shortstr_word(v : word;len : SizeInt;out s : shortstring); compilerproc;
   procedure fpc_shortstr_smallint(v : smallint;len : SizeInt;out s : shortstring); compilerproc;
-  procedure fpc_chararray_word(v : word;len : SizeInt;out a : array of char); compilerproc;
-  procedure fpc_chararray_smallint(v : smallint;len : SizeInt;out a : array of char); compilerproc;
+  procedure fpc_chararray_word(v : word;len : SizeInt;out a : array of AnsiChar); compilerproc;
+  procedure fpc_chararray_smallint(v : smallint;len : SizeInt;out a : array of AnsiChar); compilerproc;
   {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
   procedure fpc_ansistr_word(v : word;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
   procedure fpc_ansistr_smallint(v : smallint;len : SizeInt;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
@@ -198,18 +198,18 @@ procedure fpc_AnsiStr_Currency(c : currency;len,fr : SizeInt;out s : RawByteStri
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
 
 {$ifndef FPUNONE}
-procedure fpc_chararray_Float(d : ValReal;len,fr,rt : SizeInt;out a : array of char); compilerproc;
+procedure fpc_chararray_Float(d : ValReal;len,fr,rt : SizeInt;out a : array of AnsiChar); compilerproc;
 {$endif}
 {$ifndef CPUAVR}
 { currently, the avr code generator fails on this procedure, so we disable it, 
   this is not a good solution but fixing compilation of this procedure for
   avr is hard, requires significant changes to the register allocator to take
   care of different register classes }
-procedure fpc_chararray_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out a : array of char);compilerproc;
+procedure fpc_chararray_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out a : array of AnsiChar);compilerproc;
 {$endif CPUAVR}
 
-procedure fpc_chararray_bool(b : boolean;len:sizeint;out a : array of char);compilerproc;
-procedure fpc_chararray_Currency(c : Currency;len,fr : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_bool(b : boolean;len:sizeint;out a : array of AnsiChar);compilerproc;
+procedure fpc_chararray_Currency(c : Currency;len,fr : SizeInt;out a : array of AnsiChar);compilerproc;
 
 { Val() support }
 {$ifndef FPUNONE}
@@ -355,10 +355,10 @@ Function fpc_AnsiStr_To_WideStr (Const S2 : RawByteString): WideString; compiler
 Procedure fpc_WideStr_Assign (Var S1 : Pointer;S2 : Pointer); compilerproc;
 Procedure fpc_WideStr_Concat (Var DestS : Widestring;const S1,S2 : WideString); compilerproc;
 Procedure fpc_WideStr_Concat_multi (Var DestS : Widestring;const sarr:array of Widestring); compilerproc;
-Function fpc_Char_To_WideStr(const c : Char): WideString; compilerproc;
-Function fpc_PChar_To_WideStr(const p : pchar): WideString; compilerproc;
-Function fpc_CharArray_To_WideStr(const arr: array of char; zerobased: boolean = true): WideString; compilerproc;
-procedure fpc_widestr_to_chararray(out res: array of char; const src: WideString); compilerproc;
+Function fpc_Char_To_WideStr(const c : AnsiChar): WideString; compilerproc;
+Function fpc_PChar_To_WideStr(const p : PAnsiChar): WideString; compilerproc;
+Function fpc_CharArray_To_WideStr(const arr: array of AnsiChar; zerobased: boolean = true): WideString; compilerproc;
+procedure fpc_widestr_to_chararray(out res: array of AnsiChar; const src: WideString); compilerproc;
 procedure fpc_widestr_to_widechararray(out res: array of widechar; const src: WideString); compilerproc;
 Function fpc_WideStr_Compare(const S1,S2 : WideString): SizeInt; compilerproc;
 Function fpc_WideStr_Compare_equal(const S1,S2 : WideString): SizeInt; compilerproc;
@@ -396,10 +396,10 @@ Function fpc_WideStr_To_UnicodeStr (Const S2 : WideString): UnicodeString; compi
 Procedure fpc_UnicodeStr_Assign (Var S1 : Pointer;S2 : Pointer); compilerproc;
 Procedure fpc_UnicodeStr_Concat (Var DestS : Unicodestring;const S1,S2 : UnicodeString); compilerproc;
 Procedure fpc_UnicodeStr_Concat_multi (Var DestS : Unicodestring;const sarr:array of Unicodestring); compilerproc;
-Function fpc_Char_To_UnicodeStr(const c : Char): UnicodeString; compilerproc;
-Function fpc_PChar_To_UnicodeStr(const p : pchar): UnicodeString; compilerproc;
-Function fpc_CharArray_To_UnicodeStr(const arr: array of char; zerobased: boolean = true): UnicodeString; compilerproc;
-procedure fpc_unicodestr_to_chararray(out res: array of char; const src: UnicodeString); compilerproc;
+Function fpc_Char_To_UnicodeStr(const c : AnsiChar): UnicodeString; compilerproc;
+Function fpc_PChar_To_UnicodeStr(const p : PAnsiChar): UnicodeString; compilerproc;
+Function fpc_CharArray_To_UnicodeStr(const arr: array of AnsiChar; zerobased: boolean = true): UnicodeString; compilerproc;
+procedure fpc_unicodestr_to_chararray(out res: array of AnsiChar; const src: UnicodeString); compilerproc;
 procedure fpc_WideCharArray_To_ShortStr(out res : shortstring;const arr: array of widechar; zerobased: boolean = true); compilerproc;
 Function fpc_WideCharArray_To_AnsiStr(const arr: array of widechar; {$ifdef FPC_HAS_CPSTRING}cp : TSystemCodePage;{$endif FPC_HAS_CPSTRING} zerobased: boolean = true): AnsiString; compilerproc;
 {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
@@ -421,8 +421,8 @@ Procedure fpc_unicodestr_insert (Const Source : UnicodeString; Var S : UnicodeSt
 Procedure fpc_unicodestr_delete (Var S : UnicodeString; Index,Size: SizeInt); compilerproc:fpc_in_delete_x_y_z;
 {$endif VER3_0}
 function fpc_unicodestr_Unique(Var S : Pointer): Pointer; compilerproc;
-Function fpc_Char_To_UChar(const c : Char): UnicodeChar; compilerproc;
-Function fpc_UChar_To_Char(const c : UnicodeChar): Char; compilerproc;
+Function fpc_Char_To_UChar(const c : AnsiChar): UnicodeChar; compilerproc;
+Function fpc_UChar_To_Char(const c : UnicodeChar): AnsiChar; compilerproc;
 Function fpc_UChar_To_UnicodeStr(const c : UnicodeChar): UnicodeString; compilerproc;
 Function fpc_UChar_To_AnsiStr(const c : UnicodeChar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): AnsiString; compilerproc;
 function fpc_UChar_To_ShortStr(const c : WideChar): shortstring; compilerproc;
@@ -440,15 +440,15 @@ procedure fpc_PWideChar_To_ShortStr(out res : shortstring;const p : pwidechar);
 Function fpc_get_input:PText;compilerproc;
 Function fpc_get_output:PText;compilerproc;
 Procedure fpc_textinit_iso(var t : Text;nr : DWord);compilerproc;
-Procedure fpc_textinit_filename_iso(var t : Text;nr : DWord;const filename : string);compilerproc;
+Procedure fpc_textinit_filename_iso(var t : Text;nr : DWord;const filename : shortstring);compilerproc;
 Procedure fpc_textclose_iso(var t : Text);compilerproc;
 Procedure fpc_Write_End(var f:Text); compilerproc;
 Procedure fpc_Writeln_End(var f:Text); compilerproc;
-Procedure fpc_Write_Text_ShortStr(Len : Longint;var f : Text;const s : String); compilerproc;
-Procedure fpc_Write_Text_ShortStr_Iso(Len : Longint;var f : Text;const s : String); compilerproc;
-Procedure fpc_Write_Text_Pchar_as_Array(Len : Longint;var f : Text;const s : array of char; zerobased: boolean = true); compilerproc;
-Procedure fpc_Write_Text_Pchar_as_Array_Iso(Len : Longint;var f : Text;const s : array of char; zerobased: boolean = true); compilerproc;
-Procedure fpc_Write_Text_PChar_As_Pointer(Len : Longint;var f : Text;p : PChar); compilerproc;
+Procedure fpc_Write_Text_ShortStr(Len : Longint;var f : Text;const s : shortString); compilerproc;
+Procedure fpc_Write_Text_ShortStr_Iso(Len : Longint;var f : Text;const s : shortString); compilerproc;
+Procedure fpc_Write_Text_Pchar_as_Array(Len : Longint;var f : Text;const s : array of AnsiChar; zerobased: boolean = true); compilerproc;
+Procedure fpc_Write_Text_Pchar_as_Array_Iso(Len : Longint;var f : Text;const s : array of AnsiChar; zerobased: boolean = true); compilerproc;
+Procedure fpc_Write_Text_PChar_As_Pointer(Len : Longint;var f : Text;p : PAnsiChar); compilerproc;
 Procedure fpc_Write_Text_AnsiStr (Len : Longint; Var f : Text; const S : RawByteString); compilerproc;
 {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
 Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; const S : WideString); compilerproc;
@@ -485,8 +485,8 @@ procedure fpc_write_text_enum(typinfo,ord2strindex:pointer;len:sizeint;var t:tex
 Procedure fpc_Write_Text_Currency(fixkomma,Len : Longint;var t : Text;c : Currency); compilerproc;
 Procedure fpc_Write_Text_Boolean(Len : Longint;var t : Text;b : Boolean); compilerproc;
 Procedure fpc_Write_Text_Boolean_Iso(Len : Longint;var t : Text;b : Boolean); compilerproc;
-Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); compilerproc;
-Procedure fpc_Write_Text_Char_Iso(Len : Longint;var t : Text;c : Char); compilerproc;
+Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : AnsiChar); compilerproc;
+Procedure fpc_Write_Text_Char_Iso(Len : Longint;var t : Text;c : AnsiChar); compilerproc;
 {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 Procedure fpc_Write_Text_WideChar(Len : Longint;var t : Text;c : WideChar); compilerproc;
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
@@ -542,9 +542,9 @@ procedure fpc_dispinvoke_variant(dest : pvardata;var source : tvardata;  calldes
 Procedure fpc_Read_End(var f:Text); compilerproc;
 Procedure fpc_ReadLn_End(var f : Text); compilerproc;
 Procedure fpc_ReadLn_End_Iso(var f : Text); compilerproc;
-Procedure fpc_Read_Text_ShortStr(var f : Text;out s : String); compilerproc;
-Procedure fpc_Read_Text_PChar_As_Pointer(var f : Text; const s : PChar); compilerproc;
-Procedure fpc_Read_Text_PChar_As_Array(var f : Text;out s : array of char; zerobased: boolean = false); compilerproc;
+Procedure fpc_Read_Text_ShortStr(var f : Text;out s : shortString); compilerproc;
+Procedure fpc_Read_Text_PChar_As_Pointer(var f : Text; const s : PAnsiChar); compilerproc;
+Procedure fpc_Read_Text_PChar_As_Array(var f : Text;out s : array of ansichar; zerobased: boolean = false); compilerproc;
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 Procedure fpc_Read_Text_AnsiStr(var f : Text;out s : RawByteString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
@@ -554,11 +554,11 @@ Procedure fpc_Read_Text_UnicodeStr(var f : Text;out us : UnicodeString); compile
 {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
 Procedure fpc_Read_Text_WideStr(var f : Text;out ws : WideString); compilerproc;
 {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
-Procedure fpc_Read_Text_Char(var f : Text; out c : char); compilerproc;
+Procedure fpc_Read_Text_Char(var f : Text; out c : ansichar); compilerproc;
 {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
 procedure fpc_Read_Text_WideChar(var f : Text; out wc: widechar); compilerproc;
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
-Procedure fpc_Read_Text_Char_Iso(var f : Text; out c : char); compilerproc;
+Procedure fpc_Read_Text_Char_Iso(var f : Text; out c : ansichar); compilerproc;
 Procedure fpc_Read_Text_SInt(var f : Text; out l :ValSInt); compilerproc;
 Procedure fpc_Read_Text_SInt_Iso(var f : Text; out l : ValSInt); compilerproc;
 Procedure fpc_Read_Text_UInt(var f : Text; out u :ValUInt); compilerproc;
@@ -586,7 +586,7 @@ procedure fpc_Read_Text_Int64_Iso(var f : text; out i : int64); compilerproc;
 Procedure fpc_Read_Text_LongWord(var f : text; out q : longword); compilerproc;
 Procedure fpc_Read_Text_LongInt(var f : text; out i : longint); compilerproc;
 {$endif CPU16 or CPU8}
-function fpc_GetBuf_Text(var f : Text) : pchar; compilerproc;
+function fpc_GetBuf_Text(var f : Text) : PAnsiChar; compilerproc;
 function fpc_GetBuf_TypedFile(var f : TypedFile) : pointer; compilerproc;
 {$endif FPC_HAS_FEATURE_TEXTIO}
 

+ 1 - 1
rtl/inc/dos.inc

@@ -25,7 +25,7 @@ begin
       p[i]:=DirectorySeparator;
 end;
 
-procedure DoDirSeparators(p:Pchar);
+procedure DoDirSeparators(p:PAnsiChar);
 var
   i : longint;
 begin

+ 1 - 1
rtl/inc/dynlib.inc

@@ -181,7 +181,7 @@ begin
   NoDynLibsError;
 end;
 
-function NoGetLoadErrorStr: String; noreturn;
+function NoGetLoadErrorStr: AnsiString; noreturn;
 begin
   NoDynLibsError;
 end;

+ 1 - 1
rtl/inc/dynlibh.inc

@@ -35,7 +35,7 @@ type
   TGetProcAddressHandler = function(Lib: TLibHandle; const ProcName: AnsiString): {$ifdef cpui8086}FarPointer{$else}Pointer{$endif};
   TGetProcAddressOrdinalHandler = function(Lib: TLibHandle; Ordinal: TOrdinalEntry): {$ifdef cpui8086}FarPointer{$else}Pointer{$endif};
   TUnloadLibraryHandler = function(Lib: TLibHandle): Boolean;
-  TGetLoadErrorStrHandler = function: String;
+  TGetLoadErrorStrHandler = function: AnsiString;
 
   TDynLibsManager = record
     LoadLibraryU: TLoadLibraryUHandler;

+ 2 - 2
rtl/inc/dynlibs.pas

@@ -35,7 +35,7 @@ Function LoadLibrary(const Name : UnicodeString) : TLibHandle; inline;
 Function GetProcedureAddress(Lib : TlibHandle; const ProcName : AnsiString) : {$ifdef cpui8086}FarPointer{$else}Pointer{$endif}; inline;
 Function GetProcedureAddress(Lib : TLibHandle; Ordinal: TOrdinalEntry) : {$ifdef cpui8086}FarPointer{$else}Pointer{$endif}; inline;
 Function UnloadLibrary(Lib : TLibHandle) : Boolean; inline;
-Function GetLoadErrorStr: string; inline;
+Function GetLoadErrorStr: ansistring; inline;
 
 // Kylix/Delphi compability
 
@@ -88,7 +88,7 @@ begin
   Result:=System.UnloadLibrary(Lib);
 end;
 
-Function GetLoadErrorStr: String;
+Function GetLoadErrorStr: AnsiString;
 begin
   Result:=System.GetLoadErrorStr;
 end;

+ 42 - 42
rtl/inc/exeinfo.pp

@@ -50,22 +50,22 @@ type
     FunctionRelative: boolean;
     // Offset of the binary image forming permanent offset to all retrieved values
     ImgOffset: TExeOffset;
-    filename  : string;
+    filename  : shortstring;
     // Allocate static buffer for reading data
     buf       : array[0..4095] of byte;
     bufsize,
     bufcnt    : longint;
   end;
 
-function OpenExeFile(var e:TExeFile;const fn:string):boolean;
-function FindExeSection(var e:TExeFile;const secname:string;var secofs,seclen:longint):boolean;
+function OpenExeFile(var e:TExeFile;const fn:shortstring):boolean;
+function FindExeSection(var e:TExeFile;const secname:shortstring;var secofs,seclen:longint):boolean;
 function CloseExeFile(var e:TExeFile):boolean;
-function ReadDebugLink(var e:TExeFile;var dbgfn:string):boolean;
+function ReadDebugLink(var e:TExeFile;var dbgfn:shortstring):boolean;
 
 {$ifdef CPUI8086}
-procedure GetModuleByAddr(addr: farpointer; var baseaddr: farpointer; var filename: string);
+procedure GetModuleByAddr(addr: farpointer; var baseaddr: farpointer; var filename: shortstring);
 {$else CPUI8086}
-procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: string);
+procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: shortstring);
 {$endif CPUI8086}
 
 implementation
@@ -78,7 +78,7 @@ uses
 
 {$if defined(unix) and not defined(beos) and not defined(haiku)}
 
-  procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: string);
+  procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: shortstring);
     begin
       if assigned(UnixGetModuleByAddrHook) then
         UnixGetModuleByAddrHook(addr,baseaddr,filename)
@@ -96,9 +96,9 @@ uses
 {$ifdef FPC_OS_UNICODE}
     TST: array[0..Max_Path] of WideChar;
 {$else}
-    TST: array[0..Max_Path] of Char;
+    TST: array[0..Max_Path] of AnsiChar;
 {$endif FPC_OS_UNICODE}
-  procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: string);
+  procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: shortstring);
     begin
       baseaddr:=nil;
       if VirtualQuery(addr, @Tmm, SizeOf(Tmm))<>sizeof(Tmm) then
@@ -113,7 +113,7 @@ uses
 {$ifdef FPC_OS_UNICODE}
               filename:= String(PWideChar(@TST));
 {$else}
-              filename:= String(PChar(@TST));
+              filename:= String(PAnsiChar(@TST));
 {$endif FPC_OS_UNICODE}
             end;
         end;
@@ -148,7 +148,7 @@ uses
 
   function get_next_image_info(team: team_id; var cookie:longint; var info:image_info; size: size_t) : status_t;cdecl; external 'root' name '_get_next_image_info';
 
-  procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: string);
+  procedure GetModuleByAddr(addr: pointer; var baseaddr: pointer; var filename: shortstring);
     const
       B_OK = 0;
     var
@@ -167,7 +167,7 @@ uses
              (addr >= info.text) and (addr <= (info.text + info.text_size)) then
             begin
               baseaddr:=info.text;
-              filename:=PChar(@info.name);
+              filename:=PAnsiChar(@info.name);
             end;
         end;
     end;
@@ -289,14 +289,14 @@ function getByte(var f:file):byte;
   end;
 
   function get0String (var f:file) : string;
-  var c : char;
+  var c : AnsiChar;
   begin
     get0String := '';
-    c := char (getbyte(f));
+    c := AnsiChar (getbyte(f));
     while (c <> #0) do
     begin
       get0String := get0String + c;
-      c := char (getbyte(f));
+      c := AnsiChar (getbyte(f));
     end;
   end;
 
@@ -333,7 +333,7 @@ var valid : boolean;
   begin
     getFixString := '';
     for I := 1 to Len do
-      getFixString := getFixString + char (getbyte(e.f));
+      getFixString := getFixString + AnsiChar (getbyte(e.f));
   end;
 
 
@@ -394,7 +394,7 @@ begin
 end;
 
 function FindSectionNetwareNLM(var e:TExeFile;const asecname:string;var secofs,seclen:longint):boolean;
-var name : string;
+var name : shortstring;
     alignAmount : longint;
 begin
   seek(e.f,e.sechdrofs);
@@ -427,7 +427,7 @@ end;
 {$if defined(PE32) or defined(PE32PLUS) or defined(GO32V2)}
 type
   tcoffsechdr=packed record
-    name     : array[0..7] of char;
+    name     : array[0..7] of ansichar;
     vsize    : longint;
     rvaofs   : longint;
     datalen  : longint;
@@ -439,7 +439,7 @@ type
     flags    : longint;
   end;
   coffsymbol=packed record
-    name    : array[0..3] of char; { real is [0..7], which overlaps the strofs ! }
+    name    : array[0..3] of ansichar; { real is [0..7], which overlaps the strofs ! }
     strofs  : longint;
     value   : longint;
     section : smallint;
@@ -448,12 +448,12 @@ type
     aux     : byte;
   end;
 
-function FindSectionCoff(var e:TExeFile;const asecname:string;var secofs,seclen:longint):boolean;
+function FindSectionCoff(var e:TExeFile;const asecname:shortstring;var secofs,seclen:longint):boolean;
 var
   i : longint;
   sechdr     : tcoffsechdr;
-  secname    : string;
-  secnamebuf : array[0..255] of char;
+  secname    : shortstring;
+  secnamebuf : array[0..255] of ansichar;
   code,
   oldofs,
   bufsize    : longint;
@@ -696,10 +696,10 @@ end;
 {$IFDEF EMX}
 type
   TEmxHeader = packed record
-     Version: array [1..16] of char;
+     Version: array [1..16] of AnsiChar;
      Bound: word;
      AoutOfs: longint;
-     Options: array [1..42] of char;
+     Options: array [1..42] of AnsiChar;
   end;
 
   TAoutHeader = packed record
@@ -777,7 +777,7 @@ begin
 end;
 
 
-function FindSectionEMXaout (var E: TExeFile; const ASecName: string;
+function FindSectionEMXaout (var E: TExeFile; const ASecName: shortstring;
                                          var SecOfs, SecLen: longint): boolean;
 begin
  FindSectionEMXaout := false;
@@ -922,7 +922,7 @@ const
   AT_EXE_FN = 31;  {AT_EXECFN }
 
 var
-  pc : ppchar;
+  pc : PPAnsiChar;
   pat_hdr : P_AT_HDR;
   i, phdr_count : ptrint;
   phdr_size : ptruint;
@@ -956,7 +956,7 @@ begin
         if pat_hdr^.typ = AT_HDR_Addr then
           phdr := pointer(pat_hdr^.value);
         if pat_hdr^.typ = AT_EXE_FN then
-          filename:=strpas(pchar(pat_hdr^.value));
+          filename:=strpas(pansichar(pat_hdr^.value));
         inc (pointer(pat_hdr),sizeof(AT_HDR));
       end;
     if (phdr_count>0) and (phdr_size = sizeof (telfproghdr))
@@ -1071,11 +1071,11 @@ begin
 end;
 
 
-function FindSectionElf(var e:TExeFile;const asecname:string;var secofs,seclen:longint):boolean;
+function FindSectionElf(var e:TExeFile;const asecname:shortstring;var secofs,seclen:longint):boolean;
 var
   elfsec     : telfsechdr;
   secname    : string;
-  secnamebuf : array[0..255] of char;
+  secnamebuf : array[0..255] of ansichar;
   oldofs,
   bufsize,i  : longint;
 begin
@@ -1186,7 +1186,7 @@ type
   tmach_segment_command = record
     cmd     : cuint32;
     cmdsize : cuint32;
-    segname : array [0..15] of Char;
+    segname : array [0..15] of AnsiChar;
     vmaddr  : {$IFDEF CPU64}cuint64{$ELSE}cuint32{$ENDIF};
     vmsize  : {$IFDEF CPU64}cuint64{$ELSE}cuint32{$ENDIF};
     fileoff : {$IFDEF CPU64}cuint64{$ELSE}cuint32{$ENDIF};
@@ -1206,8 +1206,8 @@ type
   pmach_uuid_command = ^tmach_uuid_command;
 
   tmach_section = record
-    sectname : array [0..15] of Char;
-    segname  : array [0..15] of Char;
+    sectname : array [0..15] of AnsiChar;
+    segname  : array [0..15] of AnsiChar;
     addr     : {$IFDEF CPU64}cuint64{$ELSE}cuint32{$ENDIF};
     size     : {$IFDEF CPU64}cuint64{$ELSE}cuint32{$ENDIF};
     offset   : cuint32;
@@ -1348,7 +1348,7 @@ begin
 end;
 
 
-function FindSectionMachO(var e:TExeFile;const asecname:string;var secofs,seclen:longint):boolean;
+function FindSectionMachO(var e:TExeFile;const asecname:shortstring;var secofs,seclen:longint):boolean;
 var
    i, j: cuint32;
    cmd: pmach_load_command;
@@ -1357,7 +1357,7 @@ var
    section: pmach_section;
    mappedexe: pointer;
    mappedoffset, mappedsize: SizeUInt;
-   dwarfsecname: string;
+   dwarfsecname: shortstring;
 begin
   FindSectionMachO:=false;
   { make sure to unmap again on all exit paths }
@@ -1449,7 +1449,7 @@ end;
 Function UpdateCrc32(InitCrc:cardinal;const InBuf;InLen:LongInt):cardinal;
 var
   i : LongInt;
-  p : pchar;
+  p : pansichar;
 begin
   if Crc32Tbl[1]=0 then
    MakeCrc32Tbl;
@@ -1470,7 +1470,7 @@ end;
 
 type
   TOpenProc=function(var e:TExeFile):boolean;
-  TFindSectionProc=function(var e:TExeFile;const asecname:string;var secofs,seclen:longint):boolean;
+  TFindSectionProc=function(var e:TExeFile;const asecname:shortstring;var secofs,seclen:longint):boolean;
 
   TExeProcRec=record
     openproc : TOpenProc;
@@ -1509,7 +1509,7 @@ const
 {$endif}
    );
 
-function OpenExeFile(var e:TExeFile;const fn:string):boolean;
+function OpenExeFile(var e:TExeFile;const fn:shortstring):boolean;
 var
   ofm : word;
 begin
@@ -1550,7 +1550,7 @@ begin
 end;
 
 
-function FindExeSection(var e:TExeFile;const secname:string;var secofs,seclen:longint):boolean;
+function FindExeSection(var e:TExeFile;const secname:shortstring;var secofs,seclen:longint):boolean;
 begin
   FindExeSection:=false;
   if not e.isopen then
@@ -1561,7 +1561,7 @@ end;
 
 
 
-function CheckDbgFile(var e:TExeFile;const fn:string;dbgcrc:cardinal):boolean;
+function CheckDbgFile(var e:TExeFile;const fn:shortstring;dbgcrc:cardinal):boolean;
 var
   c      : cardinal;
   ofm    : word;
@@ -1588,9 +1588,9 @@ begin
 end;
 
 {$ifndef darwin}
-function ReadDebugLink(var e:TExeFile;var dbgfn:string):boolean;
+function ReadDebugLink(var e:TExeFile;var dbgfn:shortstring):boolean;
 var
-  dbglink : array[0..255] of char;
+  dbglink : array[0..255] of AnsiChar;
   i,
   dbglinklen,
   dbglinkofs : longint;
@@ -1632,7 +1632,7 @@ begin
     end;
 end;
 {$else}
-function ReadDebugLink(var e:TExeFile;var dbgfn:string):boolean;
+function ReadDebugLink(var e:TExeFile;var dbgfn:shortstring):boolean;
 var
    dsymexefile: TExeFile;
    execmd, dsymcmd: pmach_load_command;

+ 24 - 24
rtl/inc/extres.inc

@@ -40,7 +40,7 @@ const
 
 type
   TExtHeader = packed record
-    magic : array[0..5] of char;//'FPCRES'
+    magic : array[0..5] of AnsiChar;//'FPCRES'
     version : byte;             //EXT_CURRENT_VERSION
     endianess : byte;           //EXT_ENDIAN_BIG or EXT_ENDIAN_LITTLE
     count : longword;           //resource count
@@ -85,10 +85,10 @@ var ResHeader : PExtHeader = nil;
 *****************************************************************************)
 
 //resource functions are case insensitive... copied from genstr.inc
-function ResStrIComp(Str1, Str2 : PChar): SizeInt;
+function ResStrIComp(Str1, Str2 : PAnsiChar): SizeInt;
 var
   counter: SizeInt;
-  c1, c2: char;
+  c1, c2: AnsiChar;
 begin
   counter := 0;
   c1 := upcase(str1[counter]);
@@ -104,8 +104,8 @@ begin
 end;
 
 {!fixme!}
-//function InternalIsIntResource(aStr : pchar; out aInt : PtrUint) : boolean;
-function InternalIsIntResource(aStr : pchar; var aInt : PtrUint) : boolean;
+//function InternalIsIntResource(aStr : PAnsiChar; out aInt : PtrUint) : boolean;
+function InternalIsIntResource(aStr : PAnsiChar; var aInt : PtrUint) : boolean;
 var i : integer;
     s : shortstring;
     code : word;
@@ -134,9 +134,9 @@ begin
   GetResInfoPtr:=PResInfoNode(PtrUInt(ResHeader)+offset);
 end;
 
-function GetPchar(const offset : longword) : Pchar; inline;
+function GetPchar(const offset : longword) : PAnsiChar; inline;
 begin
-  GetPchar:=Pchar(PtrUInt(ResHeader)+offset);
+  GetPchar:=PAnsiChar(PtrUInt(ResHeader)+offset);
 end;
 
 function GetPtr(const offset : longword) : Pointer; inline;
@@ -160,7 +160,7 @@ begin
   end;
 end;
 
-function GetExtResPath : pchar;
+function GetExtResPath : PAnsiChar;
 var len, i : integer;
     pathstr : shortstring;
 begin
@@ -182,10 +182,10 @@ begin
   //writeln('Resource file is ',GetExtResPath);
 end;
 
-function BinSearchStr(arr : PResInfoNode; query : pchar; left, right : integer)
+function BinSearchStr(arr : PResInfoNode; query : PAnsiChar; left, right : integer)
 : PResInfoNode;
 var pivot, res : integer;
-    resstr : pchar;
+    resstr : PAnsiChar;
 begin
   BinSearchStr:=nil;
   while left<=right do
@@ -203,7 +203,7 @@ begin
   end;
 end;
 
-function BinSearchInt(arr : PResInfoNode; query : pchar; left, right : integer)
+function BinSearchInt(arr : PResInfoNode; query : PAnsiChar; left, right : integer)
 : PResInfoNode;
 var pivot : integer;
 begin
@@ -221,11 +221,11 @@ begin
   end;
 end;
 
-function BinSearchRes(root : PResInfoNode; aDesc : PChar) : PResInfoNode;
+function BinSearchRes(root : PResInfoNode; aDesc : PAnsiChar) : PResInfoNode;
 var aID : PtrUint;
 begin
   if InternalIsIntResource(aDesc,aID) then
-    BinSearchRes:=BinSearchInt(GetResInfoPtr(root^.subptr),PChar(aID),
+    BinSearchRes:=BinSearchInt(GetResInfoPtr(root^.subptr),PAnsiChar(aID),
       root^.ncounthandle,root^.ncounthandle+root^.idcountsize-1)
   else
     BinSearchRes:=BinSearchStr(GetResInfoPtr(root^.subptr),aDesc,0,
@@ -233,7 +233,7 @@ begin
 end;
 
 //Returns a pointer to a name node.
-function InternalFindResource(ResourceName, ResourceType: PChar):
+function InternalFindResource(ResourceName, ResourceType: PAnsiChar):
  PResInfoNode;
 begin
   InternalFindResource:=nil;
@@ -268,7 +268,7 @@ procedure InitResources;
 const
   PROT_READ  = 1;
   PROT_WRITE = 2;
-var respath : pchar;
+var respath : PAnsiChar;
     fdstat : stat;
 begin
   respath:=GetExtResPath;
@@ -322,7 +322,7 @@ end;
 
 {$IFDEF EXTRES_GENERIC}
 procedure InitResources;
-var respath : pchar;
+var respath : PAnsiChar;
     tmp : longword;
     tmpptr : pbyte;
 label ExitErrMem, ExitErrFile, ExitNoErr;
@@ -396,7 +396,7 @@ end;
 function ExtEnumResourceTypes(ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool;
 var ptr : PResInfoNode;
     totn, totid, i : longword;
-    pc : pchar;
+    pc : PAnsiChar;
 begin
   ExtEnumResourceTypes:=False;
   if ResHeader=nil then exit;
@@ -414,15 +414,15 @@ begin
   end;
   while i<totid do
   begin
-    if not EnumFunc(ModuleHandle,PChar(ptr[i].nameid),lParam) then exit;
+    if not EnumFunc(ModuleHandle,PAnsiChar(ptr[i].nameid),lParam) then exit;
     inc(i);
   end;
 end;
 
-function ExtEnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
+function ExtEnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PAnsiChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
 var ptr : PResInfoNode;
     totn, totid, i : longword;
-    pc : pchar;
+    pc : PAnsiChar;
 begin
   ExtEnumResourceNames:=False;
   if ResHeader=nil then exit;
@@ -444,12 +444,12 @@ begin
   end;
   while i<totid do
   begin
-    if not EnumFunc(ModuleHandle,ResourceType,PChar(ptr[i].nameid),lParam) then exit;
+    if not EnumFunc(ModuleHandle,ResourceType,PAnsiChar(ptr[i].nameid),lParam) then exit;
     inc(i);
   end;
 end;
 
-function ExtEnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
+function ExtEnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PAnsiChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
 var ptr : PResInfoNode;
     tot, i : integer;
 begin
@@ -468,7 +468,7 @@ begin
   end;
 end;
 
-Function ExtFindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PChar)
+Function ExtFindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PAnsiChar)
 : TFPResourceHandle;
 var ptr : PResInfoNode;
 begin
@@ -493,7 +493,7 @@ begin
 end;
 
 Function ExtFindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType,
-  ResourceName: PChar; Language : word): TFPResourceHandle;
+  ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
 const LANG_NEUTRAL = 0;
       LANG_ENGLISH = 9;
 var nameptr,ptr : PResInfoNode;

+ 1 - 1
rtl/inc/fexpand.inc

@@ -651,7 +651,7 @@ end;
    environments - DOS, OS/2, Win32). Example is 'C:\TEST'.
 
    FPC_FEXPAND_GETENV_PCHAR - an implementation of GetEnv returning
-   PChar instead of a shortstring is available (Unix) to support
+   PAnsiChar instead of a shortstring is available (Unix) to support
    long values of environment variables.
 
    FPC_FEXPAND_TILDE - expansion of '~/' to GetEnv('HOME') - Unix.

+ 5 - 5
rtl/inc/file.inc

@@ -46,7 +46,7 @@ Begin
     UnicodeString(FileRec(f).FullName):=Name;
 {$endif USE_FILEREC_FULLNAME}
 {$endif FPC_ANSI_TEXTFILEREC}
-  { null terminate, since the name array is regularly used as p(wide)char }
+  { null terminate, since the name array is regularly used as p(wide/Ansi)Char }
   FileRec(f).Name[high(FileRec(f).Name)]:=#0;
 End;
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
@@ -73,7 +73,7 @@ Begin
     UnicodeString(FileRec(f).FullName):=Name;
 {$endif USE_FILEREC_FULLNAME}
 {$endif FPC_ANSI_TEXTFILEREC}
-  { null terminate, since the name array is regularly used as p(wide)char }
+  { null terminate, since the name array is regularly used as p(wide/Ansi)Char }
   FileRec(f).Name[high(FileRec(f).Name)]:=#0;
 End;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
@@ -89,7 +89,7 @@ Begin
   InitFile(f);
   { warning: no encoding support }
   FileRec(f).Name:=Name;
-  { null terminate, since the name array is regularly used as p(wide)char }
+  { null terminate, since the name array is regularly used as p(wide/Ansi)Char }
   FileRec(f).Name[high(FileRec(f).Name)]:=#0;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 End;
@@ -629,11 +629,11 @@ Begin
 End;
 {$else FPC_HAS_FEATURE_ANSISTRINGS}
 var
-  p : array[0..255] Of Char;
+  p : array[0..255] Of AnsiChar;
 Begin
   Move(s[1],p,Length(s));
   p[Length(s)]:=#0;
-  Rename(f,Pchar(@p));
+  Rename(f,PAnsichar(@p));
 End;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 

+ 12 - 11
rtl/inc/flt_core.inc

@@ -932,7 +932,7 @@ end;
  |
  *-------------------------------------------------------*)
 {$ifdef cpujvm}
-procedure do_fillchar( var str: shortstring; pos, count: integer; c: char );
+procedure do_fillchar( var str: shortstring; pos, count: integer; c: AnsiChar );
 begin
   while count>0 do
     begin
@@ -942,7 +942,7 @@ begin
     end;
 end;
 {$else not cpujvm}
-procedure do_fillchar( var str: shortstring; pos, count: integer; c: char ); {$ifdef grisu1_inline}inline;{$endif}
+procedure do_fillchar( var str: shortstring; pos, count: integer; c: AnsiChar ); {$ifdef grisu1_inline}inline;{$endif}
 begin
   fillchar( str[pos], count, c );
 end;
@@ -1057,7 +1057,7 @@ begin
     if rounded then
         while ( n_before_dot > 0 ) do
         begin
-            str[i] := char( temp_round[j] + ord('0') );
+            str[i] := AnsiChar( temp_round[j] + ord('0') );
             inc( i );
             inc( j );
             dec( n_before_dot );
@@ -1065,7 +1065,7 @@ begin
     else
         while ( n_before_dot > 0 ) do
         begin
-            str[i] := char( digits[j] + ord('0') );
+            str[i] := AnsiChar( digits[j] + ord('0') );
             inc( i );
             inc( j );
             dec( n_before_dot );
@@ -1092,7 +1092,7 @@ begin
         if rounded then
             while ( n_after_dot > 0 ) do
             begin
-                str[i] := char( temp_round[j] + ord('0') );
+                str[i] := AnsiChar( temp_round[j] + ord('0') );
                 inc( i );
                 inc( j );
                 dec( n_after_dot );
@@ -1100,7 +1100,7 @@ begin
         else
             while ( n_after_dot > 0 ) do
             begin
-                str[i] := char( digits[j] + ord('0') );
+                str[i] := AnsiChar( digits[j] + ord('0') );
                 inc( i );
                 inc( j );
                 dec( n_after_dot );
@@ -1175,7 +1175,7 @@ begin
     inc( i );
     // Integer part
     if ( n_digits_have > 0 ) then
-        str[i] := char( digits[0] + ord('0') )
+        str[i] := AnsiChar( digits[0] + ord('0') )
     else
         str[i] := '0';
     inc( i );
@@ -1189,7 +1189,7 @@ begin
     j := 1;
     while ( j < n_digits_have ) and ( j < n_digits_req ) do
     begin
-        str[i] := char( digits[j] + ord('0') );
+        str[i] := AnsiChar( digits[j] + ord('0') );
         inc( i );
         inc( j );
     end;
@@ -1219,7 +1219,7 @@ begin
     // Exponent digits
     for j := 0 to n_exp - 1 do
     begin
-        str[i] := char( buf_exp[j] + ord('0') );
+        str[i] := AnsiChar( buf_exp[j] + ord('0') );
         inc( i );
     end;
 {$ifdef grisu1_debug}
@@ -1906,7 +1906,8 @@ end;
 (****************************************************************************)
 
 {$ifndef fpc_softfpu_implementation}
-procedure str_real_iso( len, f: longint; d: ValReal; real_type: treal_type; out s: string );
+procedure str_real_iso( len, f: longint; d: ValReal; real_type: treal_type; out s:
+shortstring );
 var
     i: integer;
 begin
@@ -2273,7 +2274,7 @@ end;
 
 (****************************************************************************)
 var
-    a: char;
+    a: AnsiChar;
     mantissa, bit_round, bit_round_mask: {$ifdef VALREAL_32} dword {$else} qword {$endif};
 {$ifdef VALREAL_80}
     mantissa_h: dword;

+ 1 - 0
rtl/inc/fpintres.pp

@@ -14,6 +14,7 @@
 
  **********************************************************************}
 unit fpintres;
+{$mode fpc}
 
 interface
 

+ 27 - 27
rtl/inc/generic.inc

@@ -58,9 +58,9 @@ end;
 
 {$ifndef FPC_HAS_SHORTSTR_CHARARRAY_INTERN_CHARMOVE}
 {$define FPC_HAS_SHORTSTR_CHARARRAY_INTERN_CHARMOVE}
-procedure fpc_shortstr_chararray_intern_charmove(const src: shortstring; out dst: array of char; const len: sizeint);
+procedure fpc_shortstr_chararray_intern_charmove(const src: shortstring; out dst: array of ansichar; const len: sizeint);
 begin
-  move(src[1],pchar(@dst)^,len);
+  move(src[1],PAnsiChar(@dst)^,len);
 end;
 {$endif FPC_HAS_SHORTSTR_CHARARRAY_INTERN_CHARMOVE}
 
@@ -619,7 +619,7 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_INDEXCHAR0}
-function IndexChar0(Const buf;len:SizeInt;b:Char):SizeInt;
+function IndexChar0(Const buf;len:SizeInt;b:AnsiChar):SizeInt;
 var
   psrc,pend : pbyte;
 begin
@@ -826,7 +826,7 @@ begin
     len:=slen;
   move(sstr^,dstr^,len+1);
   if slen>len then
-    pchar(dstr)^:=chr(len);
+    PAnsiChar(dstr)^:=chr(len);
 end;
 
 {$endif ndef FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
@@ -991,7 +991,7 @@ end;
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
 
 
-procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
+procedure fpc_pchar_to_shortstr(out res : shortstring;p:PAnsiChar);[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
 var
   l : ObjpasInt;
   s: shortstring;
@@ -1014,10 +1014,10 @@ end;
 {$ifndef cpujvm}
 
 { also define alias which can be used inside the system unit }
-procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);[external name 'FPC_PCHAR_TO_SHORTSTR'];
+procedure fpc_pchar_to_shortstr(out res : shortstring;p:PAnsiChar);[external name 'FPC_PCHAR_TO_SHORTSTR'];
 
 
-function strpas(p:pchar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
+function strpas(p:PAnsiChar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     fpc_pchar_to_shortstr(result,p);
   end;
@@ -1264,7 +1264,7 @@ function Utf8CodePointLen(P: PAnsiChar; MaxLookAhead: SizeInt; IncludeCombiningD
 
 {$ifndef FPC_SYSTEM_HAS_FPC_CHARARRAY_TO_SHORTSTR}
 
-procedure fpc_chararray_to_shortstr(out res : shortstring;const arr: array of char; zerobased: boolean = true);[public,alias:'FPC_CHARARRAY_TO_SHORTSTR']; compilerproc;
+procedure fpc_chararray_to_shortstr(out res : shortstring;const arr: array of AnsiChar; zerobased: boolean = true);[public,alias:'FPC_CHARARRAY_TO_SHORTSTR']; compilerproc;
 var
  l: ObjpasInt;
  index: ObjpasInt;
@@ -1294,7 +1294,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
 
-procedure fpc_shortstr_to_chararray(out res: array of char; const src: ShortString); compilerproc;
+procedure fpc_shortstr_to_chararray(out res: array of AnsiChar; const src: ShortString); compilerproc;
 var
   len: ObjpasInt;
 begin
@@ -1302,7 +1302,7 @@ begin
   if len > length(res) then
     len := length(res);
 {$push}{$r-}
-  { make sure we don't access char 1 if length is 0 (JM) }
+  { make sure we don't access AnsiChar 1 if length is 0 (JM) }
   if len > 0 then
     move(src[1],res[0],len);
   fillchar(res[len],length(res)-len,0);
@@ -1313,7 +1313,7 @@ end;
 
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
-function fpc_pchar_length(p:pchar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
+function fpc_pchar_length(p:PAnsiChar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
 begin
   if assigned(p) then
     Result:=IndexByte(p^,high(Result),0)
@@ -2487,7 +2487,7 @@ var
   m,m1 : longword;
   pcstart,
   pc2start,
-  pc,pc2 : pchar;
+  pc,pc2 : PAnsiChar;
   hs : string[32];
   overflow : longint;
 begin
@@ -2501,12 +2501,12 @@ begin
     end
   else
     m:=longword(l);
-  pcstart:=pchar(@hs[0]);
+  pcstart:=PAnsiChar(@hs[0]);
   pc:=pcstart;
   repeat
     m1:=m div 10;
     inc(pc);
-    pc^:=char(m-(m1*10)+byte('0'));
+    pc^:=AnsiChar(m-(m1*10)+byte('0'));
     m:=m1;
   until m=0;
   overflow:=(pc-pcstart)+(pc2-pc2start)-high(s);
@@ -2518,7 +2518,7 @@ begin
       inc(pc2);
       dec(pc);
     end;
-  s[0]:=char(pc2-pc2start);
+  s[0]:=AnsiChar(pc2-pc2start);
 end;
 
 {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
@@ -2530,18 +2530,18 @@ var
   m1 : longword;
   pcstart,
   pc2start,
-  pc,pc2 : pchar;
+  pc,pc2 : PAnsiChar;
   hs : string[32];
   overflow : longint;
 begin
   pc2start:=@s[1];
   pc2:=pc2start;
-  pcstart:=pchar(@hs[0]);
+  pcstart:=PAnsiChar(@hs[0]);
   pc:=pcstart;
   repeat
     inc(pc);
     m1:=l div 10;
-    pc^:=char(l-(m1*10)+byte('0'));
+    pc^:=AnsiChar(l-(m1*10)+byte('0'));
     l:=m1;
   until l=0;
   overflow:=(pc-pcstart)-high(s);
@@ -2553,7 +2553,7 @@ begin
       inc(pc2);
       dec(pc);
     end;
-  s[0]:=char(pc2-pc2start);
+  s[0]:=AnsiChar(pc2-pc2start);
 end;
 
 {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
@@ -2570,7 +2570,7 @@ var
   m,m1 : qword;
   pcstart,
   pc2start,
-  pc,pc2 : pchar;
+  pc,pc2 : PAnsiChar;
   hs : string[32];
   overflow : longint;
 begin
@@ -2584,12 +2584,12 @@ begin
     end
   else
     m:=qword(l);
-  pcstart:=pchar(@hs[0]);
+  pcstart:=PAnsiChar(@hs[0]);
   pc:=pcstart;
   repeat
     m1:=m div 10;
     inc(pc);
-    pc^:=char(m-(m1*10)+byte('0'));
+    pc^:=AnsiChar(m-(m1*10)+byte('0'));
     m:=m1;
   until m=0;
   overflow:=(pc-pcstart)+(pc2-pc2start)-high(s);
@@ -2601,7 +2601,7 @@ begin
       inc(pc2);
       dec(pc);
     end;
-  s[0]:=char(pc2-pc2start);
+  s[0]:=AnsiChar(pc2-pc2start);
 end;
 {$endif EXCLUDE_COMPLEX_PROCS}
 
@@ -2619,18 +2619,18 @@ var
   m1 : qword;
   pcstart,
   pc2start,
-  pc,pc2 : pchar;
+  pc,pc2 : PAnsiChar;
   hs : string[64];
   overflow : longint;
 begin
   pc2start:=@s[1];
   pc2:=pc2start;
-  pcstart:=pchar(@hs[0]);
+  pcstart:=PAnsiChar(@hs[0]);
   pc:=pcstart;
   repeat
     inc(pc);
     m1:=l div 10;
-    pc^:=char(l-(m1*10)+byte('0'));
+    pc^:=AnsiChar(l-(m1*10)+byte('0'));
     l:=m1;
   until l=0;
   overflow:=(pc-pcstart)-high(s);
@@ -2642,7 +2642,7 @@ begin
       inc(pc2);
       dec(pc);
     end;
-  s[0]:=char(pc2-pc2start);
+  s[0]:=AnsiChar(pc2-pc2start);
 end;
 {$endif EXCLUDE_COMPLEX_PROCS}
 

+ 20 - 20
rtl/inc/genstr.inc

@@ -13,7 +13,7 @@
  **********************************************************************}
 
 {$ifndef FPC_UNIT_HAS_STREND}
- Function StrEnd(P: PChar): PChar;
+ Function StrEnd(P: PAnsiChar): PAnsiChar;
  var
   counter: SizeInt;
  begin
@@ -36,7 +36,7 @@
   happen to overlap. So do it in a bit more reliable way.
   Also this implementation should not need per-platform optimization,
   given that IndexByte and Move are optimized. }
- Function StrCopy(Dest, Source:PChar): PChar;
+ Function StrCopy(Dest, Source:PAnsiChar): PAnsiChar;
  var
    counter : SizeInt;
  Begin
@@ -50,7 +50,7 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRUPPER}
- function StrUpper(P: PChar): PChar;
+ function StrUpper(P: PAnsiChar): PAnsiChar;
  var
   counter: SizeInt;
  begin
@@ -67,7 +67,7 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRLOWER}
- function StrLower(P: PChar): PChar;
+ function StrLower(P: PAnsiChar): PAnsiChar;
  var
   counter: SizeInt;
  begin
@@ -85,7 +85,7 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRSCAN}
- function StrScan(P: PChar; C: Char): PChar;
+ function StrScan(P: PAnsiChar; C: AnsiChar): PAnsiChar;
    Var
      count: SizeInt;
   Begin
@@ -113,10 +113,10 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRISCAN}
- function StrIScan(P: PChar; C: Char): PChar;
+ function StrIScan(P: PAnsiChar; C: AnsiChar): PAnsiChar;
    Var
      count: SizeInt;
-     UC: Char;
+     UC: AnsiChar;
   Begin
    UC := upcase(C);
    count := 0;
@@ -143,7 +143,7 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRRSCAN}
- function StrRScan(P: PChar; C: Char): PChar;
+ function StrRScan(P: PAnsiChar; C: AnsiChar): PAnsiChar;
  Var
   count: SizeInt;
   index: SizeInt;
@@ -171,11 +171,11 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRRISCAN}
- function StrRIScan(P: PChar; C: Char): PChar;
+ function StrRIScan(P: PAnsiChar; C: AnsiChar): PAnsiChar;
  Var
   count: SizeInt;
   index: SizeInt;
-  UC: Char;
+  UC: AnsiChar;
  Begin
    UC := upcase(C);
    count := Strlen(P);
@@ -201,7 +201,7 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRECOPY}
-  Function StrECopy(Dest, Source: PChar): PChar;
+  Function StrECopy(Dest, Source: PAnsiChar): PAnsiChar;
  { Equivalent to the following:                                          }
  {  strcopy(Dest,Source);                                                }
  {  StrECopy := StrEnd(Dest);                                            }
@@ -217,7 +217,7 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRLCOPY}
- Function StrLCopy(Dest,Source: PChar; MaxLen: SizeInt): PChar;
+ Function StrLCopy(Dest,Source: PAnsiChar; MaxLen: SizeInt): PAnsiChar;
   var
    counter: SizeInt;
  Begin
@@ -230,7 +230,7 @@
    end;
    while (Source[counter] <> #0)  and (counter < MaxLen) do
    Begin
-      Dest[counter] := char(Source[counter]);
+      Dest[counter] := AnsiChar(Source[counter]);
       Inc(counter);
    end;
    { terminate the string }
@@ -241,7 +241,7 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRCOMP}
- function StrComp(Str1, Str2 : PChar): SizeInt;
+ function StrComp(Str1, Str2 : PAnsiChar): SizeInt;
      var
       counter: SizeInt;
      Begin
@@ -258,10 +258,10 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRICOMP}
-     function StrIComp(Str1, Str2 : PChar): SizeInt;
+     function StrIComp(Str1, Str2 : PAnsiChar): SizeInt;
      var
       counter: SizeInt;
-      c1, c2: char;
+      c1, c2: AnsiChar;
      Begin
         counter := 0;
         c1 := upcase(str1[counter]);
@@ -279,10 +279,10 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRLCOMP}
-     function StrLComp(Str1, Str2 : PChar; L: SizeInt): SizeInt;
+     function StrLComp(Str1, Str2 : PAnsiChar; L: SizeInt): SizeInt;
      var
       counter: SizeInt;
-      c1, c2: char;
+      c1, c2: AnsiChar;
      Begin
         counter := 0;
        if L = 0 then
@@ -302,10 +302,10 @@
 
 
 {$ifndef FPC_UNIT_HAS_STRLICOMP}
-     function StrLIComp(Str1, Str2 : PChar; L: SizeInt): SizeInt;
+     function StrLIComp(Str1, Str2 : PAnsiChar; L: SizeInt): SizeInt;
      var
       counter: SizeInt;
-      c1, c2: char;
+      c1, c2: AnsiChar;
      Begin
         counter := 0;
        if L = 0 then

+ 1 - 1
rtl/inc/genstrs.inc

@@ -13,7 +13,7 @@
  **********************************************************************}
 
 {$ifndef FPC_UNIT_HAS_STRPCOPY}
-   function strpcopy(d : pchar;const s : string) : pchar;
+   function strpcopy(d : PAnsiChar;const s : string) : PAnsiChar;
    var
     counter : byte;
   Begin

+ 20 - 20
rtl/inc/getopts.pp

@@ -32,24 +32,24 @@ Type
   TOption = Record
     Name    : String;
     Has_arg : Integer;
-    Flag    : PChar;
-    Value   : Char;
-    Procedure SetOption(const aName:String;AHas_Arg:integer=0;AFlag:PChar=nil;AValue:Char=#0);
+    Flag    : PAnsiChar;
+    Value   : AnsiChar;
+    Procedure SetOption(const aName:String;AHas_Arg:integer=0;AFlag:PAnsiChar=nil;AValue:AnsiChar=#0);
   end;
 
   Orderings = (require_order,permute,return_in_order);
 
 Const
-  OptSpecifier : set of char=['-'];
+  OptSpecifier : set of AnsiChar=['-'];
 
 Var
   OptArg : String;
   OptInd : Longint;
   OptErr : Boolean;
-  OptOpt : Char;
+  OptOpt : AnsiChar;
 
-Function GetOpt (ShortOpts : String) : char;
-Function GetLongOpts (ShortOpts : String;LongOpts : POption;var Longind : Longint) : char;
+Function GetOpt (ShortOpts : String) : AnsiChar;
+Function GetLongOpts (ShortOpts : String;LongOpts : POption;var Longind : Longint) : AnsiChar;
 
 
 Implementation
@@ -66,24 +66,24 @@ uses SysUtils;
     type PtrInt = Integer;
 
 type
-  ppchar = ^pchar;
-  apchar = array[0..127] of pchar;
+  PPAnsiChar = ^pansichar;
+  apchar = array[0..127] of pansichar;
 
 var
   argc  : longint;
   argv  : apchar;
 
 const
-  CHAR_SIZE = SizeOf(Char);
+  CHAR_SIZE = SizeOf(AnsiChar);
 
 procedure setup_arguments;
 var
   arglen,
   count   : longint;
   argstart,
-  cmdline : pchar;
-  quote   : set of char;
-  argsbuf : array[0..127] of pchar;
+  cmdline : pansichar;
+  quote   : set of ansichar;
+  argsbuf : array[0..127] of ansipchar;
   s       : string;
   i       : integer;
 begin
@@ -146,7 +146,7 @@ end;
 
 {$ENDIF}
 
-function strpas(p : pchar) : ansistring;
+function strpas(p : pansichar) : ansistring;
 
 begin
   if p=nil then 
@@ -155,7 +155,7 @@ begin
     strpas:=p;
 end;
 
-Procedure TOption.SetOption(const aName:String;AHas_Arg:integer=0;AFlag:PChar=nil;AValue:Char=#0);
+Procedure TOption.SetOption(const aName:String;AHas_Arg:integer=0;AFlag:PAnsiChar=nil;AValue:AnsiChar=#0);
 begin
   Name:=aName; Has_Arg:=AHas_Arg; Flag:=AFlag; Value:=Avalue;
 end;
@@ -176,7 +176,7 @@ var
   bottom,
   middle,
   top,i,len : longint;
-  temp      : pchar;
+  temp      : pansichar;
 begin
   bottom:=first_nonopt;
   middle:=last_nonopt;
@@ -239,7 +239,7 @@ end;
 
 
 Function Internal_getopt (Var Optstring : string;LongOpts : POption;
-                          LongInd : pointer;Long_only : boolean ) : char;
+                          LongInd : pointer;Long_only : boolean ) : AnsiChar;
 var
   temp,endopt,
   option_index : byte;
@@ -248,7 +248,7 @@ var
   optname      : string;
   p,pfound     : POption;
   exact,ambig  : boolean;
-  c            : char;
+  c            : AnsiChar;
 begin
   optarg:='';
   if optind=0 then
@@ -506,13 +506,13 @@ begin
 end; { End of internal getopt...}
 
 
-Function GetOpt(ShortOpts : String) : char;
+Function GetOpt(ShortOpts : String) : AnsiChar;
 begin
   getopt:=internal_getopt(shortopts,nil,nil,false);
 end;
 
 
-Function GetLongOpts(ShortOpts : String;LongOpts : POption;var Longind : Longint) : char;
+Function GetLongOpts(ShortOpts : String;LongOpts : POption;var Longind : Longint) : AnsiChar;
 begin
   getlongopts:=internal_getopt(shortopts,longopts,@longind,true);
 end;

+ 22 - 22
rtl/inc/heaptrc.pp

@@ -216,12 +216,12 @@ end;
 Function UpdateCrc32(InitCrc:longword;var InBuf;InLen:ptruint):longword;
 var
   i : ptruint;
-  p : pchar;
+  p : pbyte;
 begin
   p:=@InBuf;
   for i:=1 to InLen do
    begin
-     InitCrc:=Crc32Tbl[byte(InitCrc) xor byte(p^)] xor (InitCrc shr 8);
+     InitCrc:=Crc32Tbl[byte(InitCrc) xor p^] xor (InitCrc shr 8);
      inc(p);
    end;
   UpdateCrc32:=InitCrc;
@@ -297,10 +297,10 @@ begin
     writeln(ptext, ' - ');
 
   for i:=0 to s-1 do
-    if pchar(p + sizeof(theap_mem_info) + i)^ < ' ' then
+    if pansichar(p + sizeof(theap_mem_info) + i)^ < ' ' then
       write(ptext, ' ')
     else
-      write(ptext, pchar(p + i)^);
+      write(ptext, pansichar(p + i)^);
 
   if size > maxprintedblocklength then
     writeln(ptext,'..')
@@ -407,7 +407,7 @@ end;
 
 {$ifdef EXTRA}
 procedure dump_change_after(p : pheap_mem_info;var ptext : text);
- var pp : pchar;
+ var pp : pansichar;
      i : ptruint;
 begin
   Writeln(ptext,'Marked memory at $',HexStr(pointer(p)+sizeof(theap_mem_info)),' invalid');
@@ -1254,9 +1254,9 @@ const
 type
   Pdl_info = ^dl_info;
   dl_info = record
-    dli_fname      : Pchar;
+    dli_fname      : Pansichar;
     dli_fbase      : pointer;
-    dli_sname      : Pchar;
+    dli_sname      : Pansichar;
     dli_saddr      : pointer;
   end;
 
@@ -1274,7 +1274,7 @@ function GetModuleName:string;
 {$ifdef MSWINDOWS}
 var
   sz:cardinal;
-  buf:array[0..8191] of char;
+  buf:array[0..8191] of ansichar;
 {$endif}
 {$if defined(LINUX) or defined(BSD)}
 var
@@ -1295,7 +1295,7 @@ begin
   else
     GetModuleName:=ParamStr(0);
 {$elseif defined(MSWINDOWS)}
-  sz:=_GetModuleFileNameA(hInstance,PChar(@buf),sizeof(buf));
+  sz:=_GetModuleFileNameA(hInstance,PAnsiChar(@buf),sizeof(buf));
   if sz>0 then
     setstring(GetModuleName,PAnsiChar(@buf),sz)
 {$else}
@@ -1657,15 +1657,15 @@ begin
 end;
 
 {$if defined(win32) or defined(win64)}
-   function GetEnvironmentStrings : pchar; stdcall;
+   function GetEnvironmentStrings : pansichar; stdcall;
      external 'kernel32' name 'GetEnvironmentStringsA';
-   function FreeEnvironmentStrings(p : pchar) : longbool; stdcall;
+   function FreeEnvironmentStrings(p : pansichar) : longbool; stdcall;
      external 'kernel32' name 'FreeEnvironmentStringsA';
-Function  GetEnv(envvar: string): string;
+Function  GetEnv(envvar: ansistring): ansistring;
 var
-   s : string;
+   s : ansistring;
    i : ptruint;
-   hp,p : pchar;
+   hp,p : pansichar;
 begin
    getenv:='';
    p:=GetEnvironmentStrings;
@@ -1685,7 +1685,7 @@ begin
    FreeEnvironmentStrings(p);
 end;
 {$elseif defined(wince)}
-Function GetEnv(P:string):Pchar;
+Function GetEnv(P:string):PAnsichar;
 begin
   { WinCE does not have environment strings.
     Add some way to specify heaptrc options? }
@@ -1693,11 +1693,11 @@ begin
 end;
 {$elseif defined(msdos) or defined(msxdos)}
    type
-     PFarChar=^Char;far;
+     PFarChar=^AnsiChar;far;
      PPFarChar=^PFarChar;
    var
      envp: PPFarChar;external name '__fpc_envp';
-Function GetEnv(P:string):string;
+Function GetEnv(P:ansistring):ansistring;
 var
   ep    : ppfarchar;
   pc    : pfarchar;
@@ -1734,14 +1734,14 @@ Begin
     end;
 end;
 {$else}
-Function GetEnv(P:string):Pchar;
+Function GetEnv(P:ansistring):Pansichar;
 {
   Searches the environment for a string with name p and
-  returns a pchar to it's value.
-  A pchar is used to accomodate for strings of length > 255
+  returns a pansichar to it's value.
+  A pansichar is used to accomodate for strings of length > 255
 }
 var
-  ep    : ppchar;
+  ep    : ppansichar;
   i     : ptruint;
   found : boolean;
 Begin
@@ -1773,7 +1773,7 @@ end;
 procedure LoadEnvironment;
 var
   i,j : ptruint;
-  s,s2   : string;
+  s,s2   : ansistring;
   err : word;
 begin
   s:=Getenv('HEAPTRC');

+ 15 - 15
rtl/inc/intres.inc

@@ -15,7 +15,7 @@
 type
   PResInfoNode = ^TResInfoNode;
   TResInfoNode = packed record
-    nameid : PChar;             //name / integer ID / languageID
+    nameid : PAnsiChar;             //name / integer ID / languageID
     ncounthandle : longword;    //named sub-entries count / resource handle
     idcountsize : longword;     //id sub-entries count / resource size
     subptr : PResInfoNode;      //first sub-entry pointer
@@ -75,10 +75,10 @@ end;
 
 
 //resource functions are case insensitive... copied from genstr.inc
-function ResStrIComp(Str1, Str2 : PChar): SizeInt;
+function ResStrIComp(Str1, Str2 : PAnsiChar): SizeInt;
 var
   counter: SizeInt;
-  c1, c2: char;
+  c1, c2: AnsiChar;
 begin
   counter := 0;
   c1 := upcase(str1[counter]);
@@ -94,8 +94,8 @@ begin
 end;
 
 {!fixme!}
-//function InternalIsIntResource(aStr : pchar; out aInt : PtrUint) : boolean;
-function InternalIsIntResource(aStr : pchar; var aInt : PtrUint) : boolean;
+//function InternalIsIntResource(aStr : PAnsiChar; out aInt : PtrUint) : boolean;
+function InternalIsIntResource(aStr : pansichar; var aInt : PtrUint) : boolean;
 var i : integer;
     s : shortstring;
     code : word;
@@ -119,10 +119,10 @@ begin
   end;
 end;
 
-function BinSearchStr(arr : PResInfoNode; query : pchar; left, right : integer)
+function BinSearchStr(arr : PResInfoNode; query : pansichar; left, right : integer)
 : PResInfoNode;
 var pivot, res : integer;
-    resstr : pchar;
+    resstr : pansichar;
 begin
   BinSearchStr:=nil;
   while left<=right do
@@ -140,7 +140,7 @@ begin
   end;
 end;
 
-function BinSearchInt(arr : PResInfoNode; query : pchar; left, right : integer)
+function BinSearchInt(arr : PResInfoNode; query : pansichar; left, right : integer)
 : PResInfoNode;
 var pivot : integer;
 begin
@@ -158,18 +158,18 @@ begin
   end;
 end;
 
-function BinSearchRes(root : PResInfoNode; aDesc : PChar) : PResInfoNode;
+function BinSearchRes(root : PResInfoNode; aDesc : PAnsiChar) : PResInfoNode;
 var aID : PtrUint;
 begin
   if InternalIsIntResource(aDesc,aID) then
-    BinSearchRes:=BinSearchInt(root^.subptr,PChar(aID),root^.ncounthandle,
+    BinSearchRes:=BinSearchInt(root^.subptr,PAnsiChar(aID),root^.ncounthandle,
       root^.ncounthandle+root^.idcountsize-1)
   else
     BinSearchRes:=BinSearchStr(root^.subptr,aDesc,0,root^.ncounthandle-1);
 end;
 
 //Returns a pointer to a name node.
-function InternalFindResource(ResHdr:PResHdr;ResourceName, ResourceType: PChar):
+function InternalFindResource(ResHdr:PResHdr;ResourceName, ResourceType: PAnsiChar):
  PResInfoNode;
 begin
   InternalFindResource:=nil;
@@ -230,7 +230,7 @@ begin
   end;
 end;
 
-Function IntEnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
+Function IntEnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PAnsiChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
 var ptr : PResInfoNode;
     tot, i : integer;
     res_hdr:PResHdr;
@@ -254,7 +254,7 @@ begin
   end;
 end;
 
-Function IntEnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
+Function IntEnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PAnsiChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
 var ptr : PResInfoNode;
     tot, i : integer;
     res_hdr:PResHdr;
@@ -277,7 +277,7 @@ begin
 end;
 
 Function IntFindResource(ModuleHandle: TFPResourceHMODULE; ResourceName,
-  ResourceType: PChar): TFPResourceHandle;
+  ResourceType: PAnsiChar): TFPResourceHandle;
 var ptr : PResInfoNode;
     res_hdr: PresHdr;
 begin
@@ -299,7 +299,7 @@ begin
 end;
 
 Function IntFindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType,
-  ResourceName: PChar; Language : word): TFPResourceHandle;
+  ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
 const LANG_NEUTRAL = 0;
       LANG_ENGLISH = 9;
 var nameptr,ptr : PResInfoNode;

+ 2 - 2
rtl/inc/iso7185.pp

@@ -190,7 +190,7 @@ unit iso7185;
 
     procedure Get(var t : Text);[IOCheck];
       var
-        c : char;
+        c : AnsiChar;
       Begin
         Read(t,c);
       End;
@@ -208,7 +208,7 @@ unit iso7185;
 
     procedure Get;[IOCheck];
       var
-        c : char;
+        c : AnsiChar;
       Begin
         Read(input,c);
       End;

+ 1 - 1
rtl/inc/lineinfo.pp

@@ -88,7 +88,7 @@ var
   filestab   : tstab;   { stab with current file info }
   filename,
   lastfilename,         { store last processed file }
-  dbgfn : string;
+  dbgfn : ansistring;
   lastopenstabs: Boolean; { store last result of processing a file }
 
 

+ 2 - 2
rtl/inc/lnfodwrf.pp

@@ -242,7 +242,7 @@ var
   index : TFilePos;
   baseaddr : {$ifdef cpui8086}farpointer{$else}pointer{$endif};
   filename,
-  dbgfn : string;
+  dbgfn : ansistring;
   lastfilename: string;   { store last processed file }
   lastopendwarf: Boolean; { store last result of processing a file }
 
@@ -521,7 +521,7 @@ begin
   i := 1;
   temp := ReadNext();
   while (temp > 0) do begin
-    ReadString[i] := char(temp);
+    ReadString[i] := AnsiChar(temp);
     if (i = 255) then begin
       { skip remaining characters }
       repeat

+ 19 - 19
rtl/inc/lstrings.pp

@@ -14,17 +14,17 @@
 {
   This file contains the implementation of the LongString type,
   and all things that are needed for it.
-  LongSTring is defined as a 'silent' pchar :
-  a pchar that points to :
+  LongSTring is defined as a 'silent' pansichar :
+  a pansichar that points to :
 
   @   : Longint for size
   @+4 : Unused byte;
-  @+5 : String;
+  @+5 : AnsiString;
    So LS[i] is converted to the address @LS+4+i.
 
-  pchar[0]-pchar[3] : Longint Size
-  pchar [4] : Unused
-  pchar[5] : String;
+  pansichar[0]-pansichar[3] : Longint Size
+  pansichar [4] : Unused
+  pansichar[5] : AnsiString;
 
 }
 
@@ -34,7 +34,7 @@ unit lstrings;
 
 Interface
 
-Type longstring = pchar;
+Type longstring = pansichar;
      ShortString = string;
 
 { Internal functions, will not appear in systemh.inc }
@@ -98,7 +98,7 @@ begin
   If P<>Nil then
      begin
      PLongint(P)^:=0;
-     pchar(P+4)^:=#0;
+     pansichar(P+4)^:=#0;
      end;
   NewLongString:=P;
 end;
@@ -128,7 +128,7 @@ begin
     if Size+PLongint(S1)^>MaxLen then
       Size:=Maxlen-PLongint(S1)^;
   If Size<=0 then exit;
-  Move (pchar(S2)[5],pchar(S1)[PLongint(S1)^+5],Size);
+  Move (pansichar(S2)[5],ansipchar(S1)[PLongint(S1)^+5],Size);
   PLongint(S1)^:=PLongint(S1)^+Size;
 end;
 
@@ -147,7 +147,7 @@ begin
     if Size+PLongint(S1)^>Maxlen then
       Size:=Maxlen-PLongint(S1)^;
   If Size<=0 then exit;
-  Move (S2[1],Pchar(S1)[PLongint(S1)^+5],Size);
+  Move (S2[1],PAnsiChar(S1)[PLongint(S1)^+5],Size);
   PLongint(S1)^:=PLongint(S1)^+Size;
 end;
 
@@ -165,7 +165,7 @@ begin
   Size:=PLongint(S2)^;
   if maxlen=-1 then maxlen:=255;
   If Size>maxlen then Size:=maxlen;
-  Move (Pchar(S2)[5],S1[1],Size);
+  Move (PAnsiChar(S2)[5],S1[1],Size);
   S1[0]:=chr(Size);
 end;
 
@@ -182,7 +182,7 @@ begin
   Size:=Byte(S2[0]);
   if maxlen=-1 then maxlen:=255;
   If Size>maxlen then Size:=maxlen;
-  Move (S2[1],pchar(S1)[5],Size);
+  Move (S2[1],PAnsiChar(S1)[5],Size);
   PLongint(S1)^:=Size;
 end;
 
@@ -205,7 +205,7 @@ begin
  if MaxI>PLOngint(S2)^ then MaxI:=PLongint(S2)^;
  While (i<=MaxI) and (Temp=0) do
    begin
-   Temp:= Byte( Pchar(S1)[i+4] ) - Byte( Pchar(S2)[I+4] );
+   Temp:= Byte( PAnsiChar(S1)[i+4] ) - Byte( PAnsiChar(S2)[I+4] );
    inc(i);
    end;
  if temp=0 then temp:=Plongint(S1)^-PLongint(S2)^;
@@ -231,7 +231,7 @@ begin
  if MaxI>byte(S2[0]) then MaxI:=Byte(S2[0]);
  While (i<=MaxI) and (Temp=0) do
    begin
-   Temp:=(Byte(Pchar(S1)[i+4])-Byte(S2[I]));
+   Temp:=(Byte(PAnsiChar(S1)[i+4])-Byte(S2[I]));
    inc(i);
    end;
  LongCompare:=Temp;
@@ -267,7 +267,7 @@ end;
 
 Function Copy (Const S : LongString; Index,Size : Longint) : LongString;
 
-var ResultAddress : pchar;
+var ResultAddress : PAnsiChar;
 
 begin
   ResultAddress:=NewLongString (Size);
@@ -278,7 +278,7 @@ begin
   if PLongint(S)^<Index+Size then
     Size:=PLongint(S)^-Index;
   if Size>0 then
-    Move (Pchar(S)[Index+5],ResultAddress[5],Size)
+    Move (PAnsiChar(S)[Index+5],ResultAddress[5],Size)
   Else
     Size:=0;
   PLongint(ResultAddress)^:=Size;
@@ -505,20 +505,20 @@ begin
       Size:=PLongint(s)^-Index+1;
     PLongint(s)^:=PLongint(s)^-Size;
     if Index<=Length(s) then
-      Move(pchar(s)[Index+Size+4],pchar(s)[Index+4],Length(s)-Index+1);
+      Move(PAnsiChar(s)[Index+Size+4],PAnsiChar(s)[Index+4],Length(s)-Index+1);
     end;
 end;
 
 Procedure Insert (Const Source : LongString; Var S : LongString; Index : Longint);
 
-var s3,s4 : pchar;
+var s3,s4 : PAnsiChar;
 
 begin
   if index <= 0 then index := 1;
   s3 := longString(copy (s, index, length(s)));
   if index > PLongint(s)^ then index := PLongint(S)^+1;
   PLongint(s)^ := index - 1;
-  s4 :=Pchar ( NewLongString (Plongint(Source)^) );
+  s4 :=PAnsiChar ( NewLongString (Plongint(Source)^) );
   Long_String_Concat(LongString(s4),Source,-1);
   Long_String_Concat(LongString(S4),LongString(s3),-1);
   Long_String_Concat(S,LongString(S4),-1);

+ 1 - 1
rtl/inc/macpas.pp

@@ -30,7 +30,7 @@ type
 {$ifndef FPUNONE}
   LongDouble = ValReal;
 {$endif}
-  FourCharArray = packed array[1..4] of char;
+  FourCharArray = packed array[1..4] of AnsiChar;
 
   UnsignedByte = Byte;
   UnsignedWord = Word;

+ 31 - 31
rtl/inc/objc1.inc

@@ -122,12 +122,12 @@ type
   function  objc_msgSend_fpret (self: id; op: SEL): double; cdecl; varargs; external libname name 'objc_msgSend';
 {$endif cpui386}
 
-  function sel_getName(sel: SEL): PChar; cdecl; external libname;
-  function sel_registerName(str: PChar): SEL; cdecl; external libname;
-  function object_getClassName(obj: id): PChar; cdecl; external libname;
+  function sel_getName(sel: SEL): PAnsiChar; cdecl; external libname;
+  function sel_registerName(str: PAnsiChar): SEL; cdecl; external libname;
+  function object_getClassName(obj: id): PAnsiChar; cdecl; external libname;
   function object_getIndexedIvars(obj: id ): Pointer; cdecl; external libname;
 
-  function sel_getUid(const str: PChar): SEL; cdecl; external libname;
+  function sel_getUid(const str: PAnsiChar): SEL; cdecl; external libname;
 
   function object_copy(obj:id; size:size_t):id; cdecl; external libname;
   function object_dispose(obj:id):id; cdecl; external libname;
@@ -138,20 +138,20 @@ type
   function object_getIvar(obj:id; _ivar:Ivar):id; cdecl;
   procedure object_setIvar(obj:id; _ivar:Ivar; value:id); cdecl;
 
-  function object_setInstanceVariable(obj:id; name:pchar; value:pointer):Ivar; cdecl; external libname;
-  function object_getInstanceVariable(obj:id; name:pchar; var outValue: Pointer):Ivar; cdecl; external libname;
+  function object_setInstanceVariable(obj:id; name:PAnsiChar; value:pointer):Ivar; cdecl; external libname;
+  function object_getInstanceVariable(obj:id; name:PAnsiChar; var outValue: Pointer):Ivar; cdecl; external libname;
 
-  function objc_getClass(name:pchar):id; cdecl; external libname;
-  function objc_getMetaClass(name:pchar):id; cdecl; external libname;
-  function objc_lookUpClass(name:pchar):id; cdecl; external libname;
+  function objc_getClass(name:PAnsiChar):id; cdecl; external libname;
+  function objc_getMetaClass(name:PAnsiChar):id; cdecl; external libname;
+  function objc_lookUpClass(name:PAnsiChar):id; cdecl; external libname;
   function objc_getClassList(buffer:pClass; bufferCount:cint):cint; cdecl; external libname;
 
 {$ifdef FPC_HAS_FEATURE_OBJECTIVEC1}
-  function objc_getProtocol(name:pchar): pobjc_protocol; cdecl; weakexternal libname;
+  function objc_getProtocol(name:PAnsiChar): pobjc_protocol; cdecl; weakexternal libname;
   function objc_copyProtocolList(outCount:pdword):ppobjc_protocol; cdecl; weakexternal libname;
 {$endif}
 
-  function class_getName(cls:pobjc_class):PChar; cdecl; inline;
+  function class_getName(cls:pobjc_class):PAnsiChar; cdecl; inline;
   function class_isMetaClass(cls:pobjc_class):ObjCBOOL; cdecl;
   function class_getSuperclass(cls:pobjc_class):pobjc_class; cdecl; inline;
 
@@ -160,8 +160,8 @@ type
 
   function class_getInstanceSize(cls:pobjc_class):size_t; cdecl; external libname;
 
-  function class_getInstanceVariable(cls:pobjc_class; name:pchar):Ivar; cdecl; external libname;
-  function class_getClassVariable(cls:pobjc_class; name:pchar):Ivar; cdecl; external libname;
+  function class_getInstanceVariable(cls:pobjc_class; name:PAnsiChar):Ivar; cdecl; external libname;
+  function class_getClassVariable(cls:pobjc_class; name:PAnsiChar):Ivar; cdecl; external libname;
   function class_copyIvarList(cls:pobjc_class; outCount:pdword):PIvar; cdecl; external libname;
 
   function class_getInstanceMethod(cls:pobjc_class; name:SEL):Method; cdecl; external libname;
@@ -177,31 +177,31 @@ type
   function class_createInstance(cls:pobjc_class; extraBytes:size_t):id; cdecl; external libname;
 
 (*
-  function objc_allocateClassPair(superclass:pobjc_class; name:pchar; extraBytes:size_t):pobjc_class; cdecl; external libname;
+  function objc_allocateClassPair(superclass:pobjc_class; name:PAnsiChar; extraBytes:size_t):pobjc_class; cdecl; external libname;
   procedure objc_registerClassPair(cls:pobjc_class); cdecl; external libname;
-  function objc_duplicateClass(original:pobjc_class; name:pchar; extraBytes:size_t):pobjc_class; cdecl; external libname;
+  function objc_duplicateClass(original:pobjc_class; name:PAnsiChar; extraBytes:size_t):pobjc_class; cdecl; external libname;
   procedure objc_disposeClassPair(cls:pobjc_class); cdecl; external libname;
 
-  function class_addMethod(cls:pobjc_class; name:SEL; imp:IMP; types:pchar):ObjCBOOL; cdecl; external libname;
-  function class_addIvar(cls:pobjc_class; name:pchar; size:size_t; alignment:uint8_t; types:pchar):ObjCBOOL; cdecl; external libname;
+  function class_addMethod(cls:pobjc_class; name:SEL; imp:IMP; types:PAnsiChar):ObjCBOOL; cdecl; external libname;
+  function class_addIvar(cls:pobjc_class; name:PAnsiChar; size:size_t; alignment:uint8_t; types:PAnsiChar):ObjCBOOL; cdecl; external libname;
   function class_addProtocol(cls:pobjc_class; protocol:pProtocol):ObjCBOOL; cdecl; external libname;
 *)
 
   function method_getName(m:Method):SEL; cdecl; inline;
   function method_getImplementation(m:Method):IMP; cdecl; inline;
-  function method_getTypeEncoding(m:Method):Pchar; cdecl; inline;
+  function method_getTypeEncoding(m:Method):PAnsiChar; cdecl; inline;
 
   function method_getNumberOfArguments(m:Method):dword; cdecl; external libname;
 (*
-  function method_copyReturnType(m:Method):Pchar; cdecl; weakexternal libname;
-  function method_copyArgumentType(m:Method; index:dword):Pchar; cdecl; weakexternal libname;
-  procedure method_getReturnType(m:Method; dst:pchar; dst_len:size_t); cdecl; external libname;
+  function method_copyReturnType(m:Method):PAnsiChar; cdecl; weakexternal libname;
+  function method_copyArgumentType(m:Method; index:dword):PAnsiChar; cdecl; weakexternal libname;
+  procedure method_getReturnType(m:Method; dst:PAnsiChar; dst_len:size_t); cdecl; external libname;
 
   function method_setImplementation(m:Method; imp:IMP):IMP; cdecl; external libname;
 *)
 
-  function ivar_getName(v:Ivar):Pchar; cdecl; inline;
-  function ivar_getTypeEncoding(v:Ivar):Pchar; cdecl; inline;
+  function ivar_getName(v:Ivar):PAnsiChar; cdecl; inline;
+  function ivar_getTypeEncoding(v:Ivar):PAnsiChar; cdecl; inline;
   function ivar_getOffset(v:Ivar):ptrdiff_t; cdecl; inline;
 
 (*
@@ -221,7 +221,7 @@ type
 
   objc_method1 = packed record
     method_name   : SEL;
-    method_types  : PChar;
+    method_types  : PAnsiChar;
     method_imp    : IMP;
   end;
   Pobjc_method_list1 = ^objc_method_list1;
@@ -241,8 +241,8 @@ type
   Ivar1 = Pobjc_ivar1;
   PIvar1 = ^Ivar1;
   objc_ivar1 = packed record
-    ivar_name   : PChar;
-    ivar_type   : PChar;
+    ivar_name   : PAnsiChar;
+    ivar_type   : PAnsiChar;
     ivar_offset : cint;
   {$ifdef __alpha__}
     space: cint;
@@ -278,7 +278,7 @@ type
   objc_class1 = packed record
 	  isa           : Pobjc_class1;
 	  super_class   : Pobjc_class1;
-	  name          : PChar;
+	  name          : PAnsiChar;
 	  version       : culong;
 	  info          : culong;
 	  instance_size : culong;
@@ -324,7 +324,7 @@ procedure object_setIvar(obj:id; _ivar:Ivar; value:id); cdecl;
     Pid(PtrUInt(obj) + ivar_getOffset(_ivar))^ := value;
   end;
 
-function class_getName(cls:pobjc_class):PChar; cdecl; inline;
+function class_getName(cls:pobjc_class):PAnsiChar; cdecl; inline;
   begin
     class_getName := pobjc_class1(cls)^.name;
   end;
@@ -349,17 +349,17 @@ function method_getImplementation(m:Method):IMP; cdecl; inline;
     method_getImplementation := IMP(Method1(m)^.method_imp);
   end;
 
-function method_getTypeEncoding(m:Method):Pchar; cdecl; inline;
+function method_getTypeEncoding(m:Method):PAnsiChar; cdecl; inline;
   begin
     method_getTypeEncoding := Method1(m)^.method_types;
   end;
 
-function ivar_getName(v:Ivar):Pchar; cdecl; inline;
+function ivar_getName(v:Ivar):PAnsiChar; cdecl; inline;
   begin
     ivar_getName := IVar1(v)^.ivar_name;
   end;
 
-function ivar_getTypeEncoding(v:Ivar):Pchar; cdecl; inline;
+function ivar_getTypeEncoding(v:Ivar):PAnsiChar; cdecl; inline;
   begin
     ivar_getTypeEncoding := IVar1(v)^.ivar_type;
   end;

+ 31 - 31
rtl/inc/objcnf.inc

@@ -105,7 +105,7 @@ type
 (* From Clang:
   // struct _protocol_t {
   //   id isa;  // NULL
-  //   const char * const protocol_name;
+  //   const AnsiChar * const protocol_name;
   //   const struct _protocol_list_t * protocol_list; // super protocols
   //   const struct method_list_t * const instance_methods;
   //   const struct method_list_t * const class_methods;
@@ -120,7 +120,7 @@ type
 *)
   objc_protocol = record
     isa: id;
-    protocol_name: pchar;
+    protocol_name: PAnsiChar;
     protocol_list: pointer;
     instance_methods,
     class_methods,
@@ -136,8 +136,8 @@ type
 (* From Clang:
 ///  struct _ivar_t {
 ///   unsigned long int *offset;  // pointer to ivar offset location
-///   char *name;
-///   char *type;
+///   AnsiChar *name;
+///   AnsiChar *type;
 ///   uint32_t alignment;
 ///   uint32_t size;
   
@@ -145,8 +145,8 @@ type
 *)
   objc_ivar = record
     offset: pculong;
-    name: pchar;
-    ttype: pchar;
+    name: PAnsiChar;
+    ttype: PAnsiChar;
     alignment: cuint32;
     size: cuint32;
   end;
@@ -157,8 +157,8 @@ type
   // Full definition required by the compiler, do not make opaque!
   objc_method = record
     _cmd: SEL;
-    method_type: pchar;
-    _imp: pchar;
+    method_type: PAnsiChar;
+    _imp: PAnsiChar;
   end;
   Pobjc_method = ^objc_method;
   Method = Pobjc_method;
@@ -196,12 +196,12 @@ type
   function  objc_msgSend_fpret (self: id; op: SEL): double; cdecl; varargs; external libname name 'objc_msgSend';
 {$endif cpui386}
 
-  function sel_getName(sel: SEL): PChar; cdecl; external libname;
-  function sel_registerName(str: PChar): SEL; cdecl; external libname;
-  function object_getClassName(obj: id): PChar; cdecl; external libname;
+  function sel_getName(sel: SEL): PAnsiChar; cdecl; external libname;
+  function sel_registerName(str: PAnsiChar): SEL; cdecl; external libname;
+  function object_getClassName(obj: id): PAnsiChar; cdecl; external libname;
   function object_getIndexedIvars(obj: id ): Pointer; cdecl; external libname;
 
-  function sel_getUid(const str: PChar): SEL; cdecl; external libname;
+  function sel_getUid(const str: PAnsiChar): SEL; cdecl; external libname;
 
   function object_copy(obj:id; size:size_t):id; cdecl; external libname;
   function object_dispose(obj:id):id; cdecl; external libname;
@@ -212,18 +212,18 @@ type
   function object_getIvar(obj:id; _ivar:Ivar):id; cdecl; external libname;
   procedure object_setIvar(obj:id; _ivar:Ivar; value:id); cdecl; external libname;
 
-  function object_setInstanceVariable(obj:id; name:pchar; value:pointer):Ivar; cdecl; external libname;
-  function object_getInstanceVariable(obj:id; name:pchar; var outValue: Pointer):Ivar; cdecl; external libname;
+  function object_setInstanceVariable(obj:id; name:PAnsiChar; value:pointer):Ivar; cdecl; external libname;
+  function object_getInstanceVariable(obj:id; name:PAnsiChar; var outValue: Pointer):Ivar; cdecl; external libname;
 
-  function objc_getClass(name:pchar):id; cdecl; external libname;
-  function objc_getMetaClass(name:pchar):id; cdecl; external libname;
-  function objc_lookUpClass(name:pchar):id; cdecl; external libname;
+  function objc_getClass(name:PAnsiChar):id; cdecl; external libname;
+  function objc_getMetaClass(name:PAnsiChar):id; cdecl; external libname;
+  function objc_lookUpClass(name:PAnsiChar):id; cdecl; external libname;
   function objc_getClassList(buffer:pClass; bufferCount:cint):cint; cdecl; external libname;
 
-  function objc_getProtocol(name:pchar): pobjc_protocol; cdecl; external libname;
+  function objc_getProtocol(name:PAnsiChar): pobjc_protocol; cdecl; external libname;
   function objc_copyProtocolList(outCount:pdword):ppobjc_protocol; cdecl; external libname;
 
-  function class_getName(cls:pobjc_class):PChar; cdecl; external libname;
+  function class_getName(cls:pobjc_class):PAnsiChar; cdecl; external libname;
   function class_isMetaClass(cls:pobjc_class):ObjCBOOL; cdecl; external libname;
   function class_getSuperclass(cls:pobjc_class):pobjc_class; cdecl; external libname;
 
@@ -232,8 +232,8 @@ type
 
   function class_getInstanceSize(cls:pobjc_class):size_t; cdecl; external libname;
 
-  function class_getInstanceVariable(cls:pobjc_class; name:pchar):Ivar; cdecl; external libname;
-  function class_getClassVariable(cls:pobjc_class; name:pchar):Ivar; cdecl; external libname;
+  function class_getInstanceVariable(cls:pobjc_class; name:PAnsiChar):Ivar; cdecl; external libname;
+  function class_getClassVariable(cls:pobjc_class; name:PAnsiChar):Ivar; cdecl; external libname;
   function class_copyIvarList(cls:pobjc_class; outCount:pdword):PIvar; cdecl; external libname;
 
   function class_getInstanceMethod(cls:pobjc_class; name:SEL):Method; cdecl; external libname;
@@ -250,28 +250,28 @@ type
 
   function class_createInstance(cls:pobjc_class; extraBytes:size_t):id; cdecl; external libname;
 
-  function objc_allocateClassPair(superclass:pobjc_class; name:pchar; extraBytes:size_t):pobjc_class; cdecl; external libname;
+  function objc_allocateClassPair(superclass:pobjc_class; name:PAnsiChar; extraBytes:size_t):pobjc_class; cdecl; external libname;
   procedure objc_registerClassPair(cls:pobjc_class); cdecl; external libname;
-  function objc_duplicateClass(original:pobjc_class; name:pchar; extraBytes:size_t):pobjc_class; cdecl; external libname;
+  function objc_duplicateClass(original:pobjc_class; name:PAnsiChar; extraBytes:size_t):pobjc_class; cdecl; external libname;
   procedure objc_disposeClassPair(cls:pobjc_class); cdecl; external libname;
 
-  function class_addMethod(cls:pobjc_class; name:SEL; _imp:IMP; types:pchar):ObjCBOOL; cdecl; external libname;
-  function class_addIvar(cls:pobjc_class; name:pchar; size:size_t; alignment:cuint8; types:pchar):ObjCBOOL; cdecl; external libname;
+  function class_addMethod(cls:pobjc_class; name:SEL; _imp:IMP; types:PAnsiChar):ObjCBOOL; cdecl; external libname;
+  function class_addIvar(cls:pobjc_class; name:PAnsiChar; size:size_t; alignment:cuint8; types:PAnsiChar):ObjCBOOL; cdecl; external libname;
   function class_addProtocol(cls:pobjc_class; protocol:pobjc_protocol):ObjCBOOL; cdecl; external libname;
 
   function method_getName(m:Method):SEL; cdecl; external libname;
   function method_getImplementation(m:Method):IMP; cdecl; external libname;
-  function method_getTypeEncoding(m:Method):Pchar; cdecl; external libname;
+  function method_getTypeEncoding(m:Method):PAnsichar; cdecl; external libname;
 
   function method_getNumberOfArguments(m:Method):dword; cdecl; external libname;
-  function method_copyReturnType(m:Method):Pchar; cdecl; external libname;
-  function method_copyArgumentType(m:Method; index:dword):Pchar; cdecl; external libname;
-  procedure method_getReturnType(m:Method; dst:pchar; dst_len:size_t); cdecl; external libname;
+  function method_copyReturnType(m:Method):PAnsichar; cdecl; external libname;
+  function method_copyArgumentType(m:Method; index:dword):PAnsichar; cdecl; external libname;
+  procedure method_getReturnType(m:Method; dst:PAnsiChar; dst_len:size_t); cdecl; external libname;
 
   function method_setImplementation(m:Method; imp:IMP):IMP; cdecl; external libname;
 
-  function ivar_getName(v:Ivar):Pchar; cdecl; external libname;
-  function ivar_getTypeEncoding(v:Ivar):Pchar; cdecl; external libname;
+  function ivar_getName(v:Ivar):PAnsiChar; cdecl; external libname;
+  function ivar_getTypeEncoding(v:Ivar):PAnsiChar; cdecl; external libname;
   function ivar_getOffset(v:Ivar):ptrdiff_t; cdecl; external libname;
 
   function sel_isEqual(lhs:SEL; rhs:SEL):ObjCBOOL; cdecl; external libname;

+ 3 - 3
rtl/inc/objpash.inc

@@ -390,7 +390,7 @@
          procedure(reason: FPC_Unwind_Reason_Code; exc: PFPC_Unwind_Exception); cdecl;
 
        FPC_Unwind_Exception = record
-         { qword instead of array of char to ensure proper alignment and
+         { qword instead of array of AnsiChar to ensure proper alignment and
            padding, and also easier to compare }
          exception_class: qword;
          exception_cleanup: FPC_Unwind_Exception_Cleanup_Fn;
@@ -555,12 +555,12 @@
 {$ifdef ENDIAN_BIG}
            vtInteger       : ({$IFDEF CPU64}integerdummy1 : Longint;{$ENDIF CPU64}VInteger: Longint);
            vtBoolean       : ({$IFDEF CPU64}booldummy : Longint;{$ENDIF CPU64}booldummy1,booldummy2,booldummy3: byte; VBoolean: Boolean);
-           vtChar          : ({$IFDEF CPU64}chardummy : Longint;{$ENDIF CPU64}chardummy1,chardummy2,chardummy3: byte; VChar: Char);
+           vtChar          : ({$IFDEF CPU64}chardummy : Longint;{$ENDIF CPU64}chardummy1,chardummy2,chardummy3: byte; VChar: AnsiChar);
            vtWideChar      : ({$IFDEF CPU64}widechardummy : Longint;{$ENDIF CPU64}wchardummy1,VWideChar: WideChar);
 {$else ENDIAN_BIG}
            vtInteger       : (VInteger: Longint);
            vtBoolean       : (VBoolean: Boolean);
-           vtChar          : (VChar: Char);
+           vtChar          : (VChar: AnsiChar);
            vtWideChar      : (VWideChar: WideChar);
 {$endif ENDIAN_BIG}
 {$ifndef FPUNONE}

+ 1 - 1
rtl/inc/psabiehh.inc

@@ -63,7 +63,7 @@ type
   TFPC_psabieh_exceptionClass = record
     case byte of
       0: (u: qword); {cuint64}
-      1: (a: array[0..7] of char);
+      1: (a: array[0..7] of AnsiChar);
   end;
 
 {$push}

+ 17 - 17
rtl/inc/resh.inc

@@ -18,7 +18,7 @@ type
   {roozbeh : maybe it shoud be moved after ifndef mswindows,as there is one declared in wince,base.inc}
   MAKEINTRESOURCE = pwidechar;
 {$else}
-  MAKEINTRESOURCE = pchar;
+  MAKEINTRESOURCE = PAnsiChar;
 {$endif}  
 {$endif not Win16}
   
@@ -51,12 +51,12 @@ const
 
 // Win32 API compatible Resource callbacks
 type
-  EnumResTypeProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; lParam : PtrInt) : LongBool; stdcall;
-  EnumResNameProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; lParam : PtrInt) : LongBool; stdcall;
-  EnumResLangProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; IDLanguage : word; lParam : PtrInt) : LongBool; stdcall;
+  EnumResTypeProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType : PAnsiChar; lParam : PtrInt) : LongBool; stdcall;
+  EnumResNameProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PAnsiChar; lParam : PtrInt) : LongBool; stdcall;
+  EnumResLangProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PAnsiChar; IDLanguage : word; lParam : PtrInt) : LongBool; stdcall;
 
 // Useful functions (macros in win32 headers)
-function Is_IntResource(aStr : pchar) : boolean; {$ifdef SYSTEMINLINE}inline;{$endif}
+function Is_IntResource(aStr : PAnsiChar) : boolean; {$ifdef SYSTEMINLINE}inline;{$endif}
 function MakeLangID(primary,sub : word) : word; {$ifdef SYSTEMINLINE}inline;{$endif}
 
 // Win32 API compatible Resource functions
@@ -64,11 +64,11 @@ function MakeLangID(primary,sub : word) : word; {$ifdef SYSTEMINLINE}inline;{$en
 Function HINSTANCE : TFPResourceHMODULE;
 {$endif Win16}
 Function EnumResourceTypes(ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool;
-Function EnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
-Function EnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
+Function EnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PAnsiChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
+Function EnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PAnsiChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
 {$ifndef Win16}
-Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PChar): TFPResourceHandle;
-Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PChar; Language : word): TFPResourceHandle;
+Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PAnsiChar): TFPResourceHandle;
+Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
 Function LoadResource(ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): TFPResourceHGLOBAL;
 Function SizeofResource(ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): LongWord;
 Function LockResource(ResData: TFPResourceHGLOBAL): Pointer;
@@ -79,10 +79,10 @@ Function FreeResource(ResData: TFPResourceHGLOBAL): LongBool;
 Function FindResource(ModuleHandle: TFPResourceHMODULE; const ResourceName, ResourceType: AnsiString): TFPResourceHandle;
 Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; const ResourceType, ResourceName: AnsiString; Language : word): TFPResourceHandle;
 {$ifndef Win16}
-Function FindResource(ModuleHandle: TFPResourceHMODULE; const ResourceName: AnsiString; ResourceType: PChar): TFPResourceHandle;
-Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType: PChar; const ResourceName: AnsiString; Language : word): TFPResourceHandle;
-Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName: PChar; const ResourceType: AnsiString): TFPResourceHandle;
-Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; const ResourceType: AnsiString; ResourceName: PChar; Language : word): TFPResourceHandle;
+Function FindResource(ModuleHandle: TFPResourceHMODULE; const ResourceName: AnsiString; ResourceType: PAnsiChar): TFPResourceHandle;
+Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType: PAnsiChar; const ResourceName: AnsiString; Language : word): TFPResourceHandle;
+Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName: PAnsiChar; const ResourceType: AnsiString): TFPResourceHandle;
+Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; const ResourceType: AnsiString; ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
 {$endif Win16}
 {$endif}
 
@@ -90,10 +90,10 @@ type
   TResourceManager = record
     HINSTANCEFunc : function : TFPResourceHMODULE;
     EnumResourceTypesFunc : function (ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool;
-    EnumResourceNamesFunc : function (ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
-    EnumResourceLanguagesFunc : function (ModuleHandle : TFPResourceHMODULE; ResourceType,ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
-    FindResourceFunc : function (ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PChar): TFPResourceHandle;
-    FindResourceExFunc : function (ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PChar; Language : word): TFPResourceHandle;
+    EnumResourceNamesFunc : function (ModuleHandle : TFPResourceHMODULE; ResourceType : PAnsiChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
+    EnumResourceLanguagesFunc : function (ModuleHandle : TFPResourceHMODULE; ResourceType,ResourceName : PAnsiChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
+    FindResourceFunc : function (ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PAnsiChar): TFPResourceHandle;
+    FindResourceExFunc : function (ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
     LoadResourceFunc : function (ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): TFPResourceHGLOBAL;
     SizeofResourceFunc : function (ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): LongWord;
     LockResourceFunc : function (ResData: TFPResourceHGLOBAL): Pointer;

+ 1 - 1
rtl/inc/rtti.inc

@@ -178,7 +178,7 @@ begin
     tkWstring,tkUString,
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
     tkInterface:
-      PPchar(Data)^:=Nil;
+      PPAnsiChar(Data)^:=Nil;
     tkArray:
       arrayrtti(data,typeinfo,@int_initialize);
 {$ifdef FPC_HAS_FEATURE_OBJECTS}

+ 38 - 38
rtl/inc/sstrings.inc

@@ -101,7 +101,7 @@ end;
 
 {$ifndef FPC_HAS_SHORTSTR_INSERT_CHAR}
 {$define FPC_HAS_SHORTSTR_INSERT_CHAR}
-procedure {$ifdef ver3_0}insert{$else}fpc_shortstr_insert_char{$endif}(source : Char;var s : shortstring;index : SizeInt);
+procedure {$ifdef ver3_0}insert{$else}fpc_shortstr_insert_char{$endif}(source : AnsiChar;var s : shortstring;index : SizeInt);
 var
   indexlen : SizeInt;
 begin
@@ -128,7 +128,7 @@ end;
 function pos(const substr : shortstring;const s : shortstring; Offset : Sizeint = 1):SizeInt;
 var
   i,MaxLen : SizeInt;
-  pc : pchar;
+  pc : PAnsiChar;
 begin
   Pos:=0;
   if (Length(SubStr)>0) and (Offset>0) and (Offset<=Length(S)) then
@@ -154,11 +154,11 @@ end;
 
 {$ifndef FPC_HAS_SHORTSTR_POS_CHAR}
 {$define FPC_HAS_SHORTSTR_POS_CHAR}
-{Faster when looking for a single char...}
-function pos(c:char;const s:shortstring; Offset : Sizeint = 1 ):SizeInt;
+{Faster when looking for a single AnsiChar...}
+function pos(c:ansichar;const s:shortstring; Offset : Sizeint = 1 ):SizeInt;
 var
   i : SizeInt;
-  pc : pchar;
+  pc : PAnsiChar;
 begin
   Pos:=0;
   if (Offset<1) or (Offset>Length(S)) then
@@ -178,7 +178,7 @@ end;
 {$endif FPC_HAS_SHORTSTR_POS_CHAR}
 
 
-function fpc_char_copy(c:char;index : SizeInt;count : SizeInt): shortstring;compilerproc;
+function fpc_char_copy(c:ansichar;index : SizeInt;count : SizeInt): shortstring;compilerproc;
 begin
   if (index=1) and (Count>0) then
    fpc_char_Copy:=c
@@ -186,7 +186,7 @@ begin
    fpc_char_Copy:='';
 end;
 
-function pos(const substr : shortstring;c:char;  Offset : Sizeint = 1): SizeInt;
+function pos(const substr : shortstring;c:Ansichar;  Offset : Sizeint = 1): SizeInt;
 begin
   if (length(substr)=1) and (substr[1]=c) and (Offset=1) then
    Pos:=1
@@ -205,14 +205,14 @@ const
 
 {$ifndef FPC_UPCASE_CHAR}
 {$define FPC_UPCASE_CHAR}
-function upcase(c : char) : char;
+function upcase(c : Ansichar) : Ansichar;
 {$IFDEF IBM_CHAR_SET}
 var
   i : ObjpasInt;
 {$ENDIF}
 begin
   if (c in ['a'..'z']) then
-    upcase:=char(byte(c)-32)
+    upcase:=AnsiChar(byte(c)-32)
   else
 {$IFDEF IBM_CHAR_SET}
     begin
@@ -244,14 +244,14 @@ end;
 
 {$ifndef FPC_LOWERCASE_CHAR}
 {$define FPC_LOWERCASE_CHAR}
-function lowercase(c : char) : char;overload;
+function lowercase(c : AnsiChar) : AnsiChar;overload;
 {$IFDEF IBM_CHAR_SET}
 var
   i : ObjpasInt;
 {$ENDIF}
 begin
   if (c in ['A'..'Z']) then
-   lowercase:=char(byte(c)+32)
+   lowercase:=AnsiChar(byte(c)+32)
   else
 {$IFDEF IBM_CHAR_SET}
    begin
@@ -281,13 +281,13 @@ end;
 {$endif FPC_LOWERCASE_SHORTSTR}
 
 const
-  HexTbl : array[0..15] of char='0123456789ABCDEF';
+  HexTbl : array[0..15] of AnsiChar='0123456789ABCDEF';
 
 function hexstr(val : longint;cnt : byte) : shortstring;
 var
   i : ObjpasInt;
 begin
-  hexstr[0]:=char(cnt);
+  hexstr[0]:=AnsiChar(cnt);
   for i:=cnt downto 1 do
    begin
      hexstr[i]:=hextbl[val and $f];
@@ -299,7 +299,7 @@ function octstr(val : longint;cnt : byte) : shortstring;
 var
   i : ObjpasInt;
 begin
-  octstr[0]:=char(cnt);
+  octstr[0]:=AnsiChar(cnt);
   for i:=cnt downto 1 do
    begin
      octstr[i]:=hextbl[val and 7];
@@ -312,10 +312,10 @@ function binstr(val : longint;cnt : byte) : shortstring;
 var
   i : ObjpasInt;
 begin
-  binstr[0]:=char(cnt);
+  binstr[0]:=AnsiChar(cnt);
   for i:=cnt downto 1 do
    begin
-     binstr[i]:=char(48+val and 1);
+     binstr[i]:=AnsiChar(48+val and 1);
      val:=val shr 1;
    end;
 end;
@@ -325,7 +325,7 @@ function hexstr(val : int64;cnt : byte) : shortstring;
 var
   i : ObjpasInt;
 begin
-  hexstr[0]:=char(cnt);
+  hexstr[0]:=AnsiChar(cnt);
   for i:=cnt downto 1 do
    begin
      hexstr[i]:=hextbl[val and $f];
@@ -338,7 +338,7 @@ function octstr(val : int64;cnt : byte) : shortstring;
 var
   i : ObjpasInt;
 begin
-  octstr[0]:=char(cnt);
+  octstr[0]:=AnsiChar(cnt);
   for i:=cnt downto 1 do
    begin
      octstr[i]:=hextbl[val and 7];
@@ -351,10 +351,10 @@ function binstr(val : int64;cnt : byte) : shortstring;
 var
   i : ObjpasInt;
 begin
-  binstr[0]:=char(cnt);
+  binstr[0]:=AnsiChar(cnt);
   for i:=cnt downto 1 do
    begin
-     binstr[i]:=char(48+val and 1);
+     binstr[i]:=AnsiChar(48+val and 1);
      val:=val shr 1;
    end;
 end;
@@ -518,7 +518,7 @@ type
   Tenum_typeinfo={$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}packed{$endif}record
     kind:TTypeKind; { always tkEnumeration }
     num_chars:byte;
-    chars:array[0..0] of char; { variable length with size of num_chars }
+    chars:array[0..0] of AnsiChar; { variable length with size of num_chars }
   end;
 
 {$push}
@@ -689,7 +689,7 @@ procedure fpc_shortstr_currency({$ifdef cpujvm}constref{$endif} c : currency; le
 const
   MinLen = 8; { Minimal string length in scientific format }
 var
-  buf : array[1..19] of char;
+  buf : array[1..19] of AnsiChar;
   i,j,k,reslen,tlen,sign,r,point : ObjpasInt;
   ic : qword;
 begin
@@ -865,10 +865,10 @@ begin
 end;
 
 {
-   Array Of Char Str() helpers
+   Array Of AnsiChar Str() helpers
 }
 
-procedure fpc_chararray_sint(v : valsint;len : SizeInt;out a:array of char);compilerproc;
+procedure fpc_chararray_sint(v : valsint;len : SizeInt;out a:array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -884,7 +884,7 @@ begin
 end;
 
 
-procedure fpc_chararray_uint(v : valuint;len : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_uint(v : valuint;len : SizeInt;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -902,7 +902,7 @@ end;
 
 {$ifndef CPU64}
 
-procedure fpc_chararray_qword(v : qword;len : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_qword(v : qword;len : SizeInt;out a : array of AnsiChar);compilerproc;
 {$ifdef EXCLUDE_COMPLEX_PROCS}
 begin
   runerror(219);
@@ -924,7 +924,7 @@ end;
 {$endif EXCLUDE_COMPLEX_PROCS}
 
 
-procedure fpc_chararray_int64(v : int64;len : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_int64(v : int64;len : SizeInt;out a : array of AnsiChar);compilerproc;
 {$ifdef EXCLUDE_COMPLEX_PROCS}
 begin
   runerror(219);
@@ -950,7 +950,7 @@ end;
 
 {$if defined(CPU16) or defined(CPU8)}
 
-procedure fpc_chararray_longword(v : longword;len : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_longword(v : longword;len : SizeInt;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -966,7 +966,7 @@ begin
 end;
 
 
-procedure fpc_chararray_longint(v : longint;len : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_longint(v : longint;len : SizeInt;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -982,7 +982,7 @@ begin
 end;
 
 
-procedure fpc_chararray_word(v : word;len : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_word(v : word;len : SizeInt;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -998,7 +998,7 @@ begin
 end;
 
 
-procedure fpc_chararray_smallint(v : smallint;len : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_smallint(v : smallint;len : SizeInt;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -1017,7 +1017,7 @@ end;
 
 
 {$ifndef FPUNONE}
-procedure fpc_chararray_Float(d : ValReal;len,fr,rt : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_Float(d : ValReal;len,fr,rt : SizeInt;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -1036,7 +1036,7 @@ end;
   this is not a good solution but fixing compilation of this procedure for
   avr is hard, requires significant changes to the register allocator to take
   care of different register classes }
-procedure fpc_chararray_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out a : array of char);compilerproc;
+procedure fpc_chararray_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -1054,7 +1054,7 @@ begin
 end;
 {$endif not FPC_STR_ENUM_INTERN}
 
-procedure fpc_chararray_bool(b : boolean;len:sizeint;out a : array of char);compilerproc;
+procedure fpc_chararray_bool(b : boolean;len:sizeint;out a : array of AnsiChar);compilerproc;
 var
   ss : shortstring;
   maxlen : SizeInt;
@@ -1070,7 +1070,7 @@ end;
 
 {$ifndef FPC_HAS_CHARARRAY_CURRENCY}
 {$define FPC_HAS_CHARARRAY_CURRENCY}
-procedure fpc_chararray_Currency(c : Currency;len,fr : SizeInt;out a : array of char);compilerproc;
+procedure fpc_chararray_Currency(c : Currency;len,fr : SizeInt;out a : array of AnsiChar);compilerproc;
 {$ifdef EXCLUDE_COMPLEX_PROCS}
 begin
   runerror(217);
@@ -1643,7 +1643,7 @@ function fpc_val_enum_shortstr(str2ordindex:pointer;const s:shortstring;out code
      comparison.}
 
     var i,l:byte;
-        c1,c2:char;
+        c1,c2:AnsiChar;
 
     begin
       l:=length(s1);
@@ -1871,7 +1871,7 @@ end;
 
 {$ifndef FPC_HAS_SETSTRING_SHORTSTR}
 {$define FPC_HAS_SETSTRING_SHORTSTR}
-Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_shortstr{$else}SetString{$endif}(Out S : Shortstring; Buf : PChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
+Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_shortstr{$else}SetString{$endif}(Out S : Shortstring; Buf : PAnsiChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
 begin
   If Len > High(S) then
     Len := High(S);
@@ -1890,7 +1890,7 @@ var
   c1, c2: Byte;
   i: SizeInt;
   L1, L2, Count: SizeInt;
-  P1, P2: PChar;
+  P1, P2: PAnsiChar;
 begin
   L1 := Length(S1);
   L2 := Length(S2);

+ 32 - 32
rtl/inc/strings.pp

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
     Copyright (c) 1999-2000 by the Free Pascal development team.
 
-    Strings unit for PChar (asciiz/C compatible strings) handling
+    Strings unit for PAnsiChar (asciiz/C compatible strings) handling
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -18,86 +18,86 @@ unit Strings;
 interface
 
     { Implemented in System Unit }
-    function strpas(p:pchar):shortstring;inline;
+    function strpas(p:PAnsiChar):shortstring;inline;
 
-    function strlen(p:pchar):sizeint;external name 'FPC_PCHAR_LENGTH';
+    function strlen(p:PAnsiChar):sizeint;external name 'FPC_PCHAR_LENGTH';
 
     { Converts a Pascal string to a null-terminated string }
-    function strpcopy(d : pchar;const s : string) : pchar;
+    function strpcopy(d : PAnsiChar;const s : string) : PAnsiChar;
 
     { Copies source to dest, returns a pointer to dest }
-    function strcopy(dest,source : pchar) : pchar; overload;
+    function strcopy(dest,source : PAnsiChar) : PAnsiChar; overload;
 
     { Copies at most maxlen bytes from source to dest. }
     { Returns a pointer to dest }
-    function strlcopy(dest,source : pchar;maxlen : SizeInt) : pchar; overload;
+    function strlcopy(dest,source : PAnsiChar;maxlen : SizeInt) : PAnsiChar; overload;
 
     { Copies source to dest and returns a pointer to the terminating }
     { null character.    }
-    function strecopy(dest,source : pchar) : pchar;
+    function strecopy(dest,source : PAnsiChar) : PAnsiChar;
 
     { Returns a pointer tro the terminating null character of p }
-    function strend(p : pchar) : pchar;
+    function strend(p : PAnsiChar) : PAnsiChar;
 
     { Appends source to dest, returns a pointer do dest}
-    function strcat(dest,source : pchar) : pchar;
+    function strcat(dest,source : PAnsiChar) : PAnsiChar;
 
     { Compares str1 und str2, returns }
     { a value <0 if str1<str2;        }
     {  0 when str1=str2               }
     { and a value >0 if str1>str2     }
-    function strcomp(str1,str2 : pchar) : SizeInt;
+    function strcomp(str1,str2 : PAnsiChar) : SizeInt;
 
     { The same as strcomp, but at most l characters are compared  }
-    function strlcomp(str1,str2 : pchar;l : SizeInt) : SizeInt;
+    function strlcomp(str1,str2 : PAnsiChar;l : SizeInt) : SizeInt;
 
     { The same as strcomp but case insensitive }
-    function stricomp(str1,str2 : pchar) : SizeInt;
+    function stricomp(str1,str2 : PAnsiChar) : SizeInt;
 
     { The same as stricomp, but at most l characters are compared }
-    function strlicomp(str1,str2 : pchar;l : SizeInt) : SizeInt;
+    function strlicomp(str1,str2 : PAnsiChar;l : SizeInt) : SizeInt;
 
     { Copies l characters from source to dest, returns dest. }
-    function strmove(dest,source : pchar;l : SizeInt) : pchar;
+    function strmove(dest,source : PAnsiChar;l : SizeInt) : PAnsiChar;
 
     { Appends at most l characters from source to dest }
-    function strlcat(dest,source : pchar;l : SizeInt) : pchar;
+    function strlcat(dest,source : PAnsiChar;l : SizeInt) : PAnsiChar;
 
     { Returns a pointer to the first occurrence of c in p }
     { If c doesn't occur, nil is returned }
-    function strscan(p : pchar;c : char) : pchar;
+    function strscan(p : PAnsiChar;c : AnsiChar) : PAnsiChar;
 
     { The same as strscan but case insensitive }
-    function striscan(p : pchar;c : char) : pchar;
+    function striscan(p : PAnsiChar;c : AnsiChar) : PAnsiChar;
 
     { Returns a pointer to the last occurrence of c in p }
     { If c doesn't occur, nil is returned }
-    function strrscan(p : pchar;c : char) : pchar;
+    function strrscan(p : PAnsiChar;c : AnsiChar) : PAnsiChar;
 
     { The same as strrscan but case insensitive }
-    function strriscan(p : pchar;c : char) : pchar;
+    function strriscan(p : PAnsiChar;c : AnsiChar) : PAnsiChar;
 
     { converts p to all-lowercase, returns p }
-    function strlower(p : pchar) : pchar;
+    function strlower(p : PAnsiChar) : PAnsiChar;
 
     { converts p to all-uppercase, returns p }
-    function strupper(p : pchar) : pchar;
+    function strupper(p : PAnsiChar) : PAnsiChar;
 
     { Returns a pointer to the first occurrence of str2 in }
     { str1 Otherwise returns nil }
-    function strpos(str1,str2 : pchar) : pchar;
+    function strpos(str1,str2 : PAnsiChar) : PAnsiChar;
 
     { The same as strpos but case insensitive       }
-    function stripos(str1,str2 : pchar) : pchar;
+    function stripos(str1,str2 : PAnsiChar) : PAnsiChar;
 
     { Makes a copy of p on the heap, and returns a pointer to this copy  }
-    function strnew(p : pchar) : pchar;
+    function strnew(p : PAnsiChar) : PAnsiChar;
 
-    { Allocates L bytes on the heap, returns a pchar pointer to it }
-    function stralloc(L : SizeInt) : pchar;
+    { Allocates L bytes on the heap, returns a PAnsiChar pointer to it }
+    function stralloc(L : SizeInt) : PAnsiChar;
 
     { Releases a null-terminated string from the heap }
-    procedure strdispose(p : pchar);
+    procedure strdispose(p : PAnsiChar);
 
 implementation
 
@@ -121,22 +121,22 @@ implementation
 { Functions, different from the one in sysutils }
 
 
-    procedure fpc_pchar_to_shortstr(var res : openstring;p:pchar);[external name 'FPC_PCHAR_TO_SHORTSTR'];
+    procedure fpc_pchar_to_shortstr(var res : openstring;p:PAnsiChar);[external name 'FPC_PCHAR_TO_SHORTSTR'];
 
 
-    function strpas(p:pchar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
+    function strpas(p:PAnsiChar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
       begin
         fpc_pchar_to_shortstr(strpas,p);
       end;
 
-    function stralloc(L : SizeInt) : pchar;
+    function stralloc(L : SizeInt) : PAnsiChar;
 
       begin
          StrAlloc:=Nil;
          GetMem (Stralloc,l);
       end;
 
-    function strnew(p : pchar) : pchar;
+    function strnew(p : PAnsiChar) : PAnsiChar;
 
       var
          len : SizeInt;
@@ -151,7 +151,7 @@ implementation
            move(p^,strnew^,len);
       end;
 
-    procedure strdispose(p : pchar);
+    procedure strdispose(p : PAnsiChar);
 
       begin
          if p<>nil then

+ 8 - 8
rtl/inc/stringsi.inc

@@ -13,17 +13,17 @@
 
  **********************************************************************}
 
-    function strcat(dest,source : pchar) : pchar;
+    function strcat(dest,source : PAnsiChar) : PAnsiChar;
 
       begin
         strcopy(strend(dest),source);
         strcat:=dest;
       end;
 
-    function strlcat(dest,source : pchar;l : SizeInt) : pchar;
+    function strlcat(dest,source : PAnsiChar;l : SizeInt) : PAnsiChar;
 
       var
-         destend : pchar;
+         destend : PAnsiChar;
 
       begin
          destend:=strend(dest);
@@ -33,7 +33,7 @@
          strlcat:=dest;
       end;
 
-    function strmove(dest,source : pchar;l : SizeInt) : pchar;
+    function strmove(dest,source : PAnsiChar;l : SizeInt) : PAnsiChar;
 
       begin
          move(source^,dest^,l);
@@ -41,9 +41,9 @@
       end;
 
 
-    function strpos(str1,str2 : pchar) : pchar;
+    function strpos(str1,str2 : PAnsiChar) : PAnsiChar;
       var
-         p : pchar;
+         p : PAnsiChar;
          lstr2 : SizeInt;
       begin
          strpos:=nil;
@@ -65,9 +65,9 @@
            end;
       end;
 
-    function stripos(str1,str2 : pchar) : pchar;
+    function stripos(str1,str2 : PAnsiChar) : PAnsiChar;
       var
-         p : pchar;
+         p : PAnsiChar;
          lstr2 : SizeInt;
       begin
          stripos:=nil;

+ 19 - 19
rtl/inc/sysres.inc

@@ -17,7 +17,7 @@
                              Utility functions
 *****************************************************************************)
 
-function Is_IntResource(aStr : pchar) : boolean; {$ifdef SYSTEMINLINE}inline;{$endif}
+function Is_IntResource(aStr : PAnsiChar) : boolean; {$ifdef SYSTEMINLINE}inline;{$endif}
 begin
   Result:=((PtrUInt(aStr) shr 16)=0);
 end;
@@ -35,38 +35,38 @@ end;
 Function FindResource(ModuleHandle: TFPResourceHMODULE; const ResourceName, ResourceType: AnsiString): TFPResourceHandle;
 
 begin
-  Result:=FindResource(ModuleHandle,PChar(ResourceName),PChar(ResourceType));
+  Result:=FindResource(ModuleHandle,PAnsiChar(ResourceName),PAnsiChar(ResourceType));
 end;
 
 Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; const ResourceType, ResourceName: AnsiString; Language : word): TFPResourceHandle;
 
 begin
-  Result:=FindResourceEx(ModuleHandle,PChar(ResourceType),PChar(ResourceName),Language);
+  Result:=FindResourceEx(ModuleHandle,PAnsiChar(ResourceType),PAnsiChar(ResourceName),Language);
 end;
 
 {$ifndef Win16}
-Function FindResource(ModuleHandle: TFPResourceHMODULE; const ResourceName: AnsiString; ResourceType: PChar): TFPResourceHandle;
+Function FindResource(ModuleHandle: TFPResourceHMODULE; const ResourceName: AnsiString; ResourceType: PAnsiChar): TFPResourceHandle;
 
 begin
-  Result:=FindResource(ModuleHandle,PChar(ResourceName),ResourceType);
+  Result:=FindResource(ModuleHandle,PAnsiChar(ResourceName),ResourceType);
 end;
 
-Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType: PChar; const ResourceName: AnsiString; Language : word): TFPResourceHandle;
+Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType: PAnsiChar; const ResourceName: AnsiString; Language : word): TFPResourceHandle;
 
 begin
-  Result:=FindResourceEx(ModuleHandle,ResourceType,PChar(ResourceName),Language);
+  Result:=FindResourceEx(ModuleHandle,ResourceType,PAnsiChar(ResourceName),Language);
 end;
 
-Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName: PChar; const ResourceType: AnsiString): TFPResourceHandle;
+Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName: PAnsiChar; const ResourceType: AnsiString): TFPResourceHandle;
 
 begin
-  Result:=FindResource(ModuleHandle,ResourceName,PChar(ResourceType));
+  Result:=FindResource(ModuleHandle,ResourceName,PAnsiChar(ResourceType));
 end;
 
-Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; const ResourceType: AnsiString; ResourceName: PChar; Language : word): TFPResourceHandle;
+Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; const ResourceType: AnsiString; ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
 
 begin
-  Result:=FindResourceEx(ModuleHandle,PChar(ResourceType),ResourceName,Language);
+  Result:=FindResourceEx(ModuleHandle,PAnsiChar(ResourceType),ResourceName,Language);
 end;
 {$endif Win16}
 {$endif}
@@ -87,22 +87,22 @@ begin
   Result:=False;
 end;
 
-Function DefaultEnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
+Function DefaultEnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PAnsiChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
 begin
   Result:=False;
 end;
 
-Function DefaultEnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
+Function DefaultEnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PAnsiChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
 begin
   Result:=False;
 end;
 
-Function DefaultFindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PChar): TFPResourceHandle;
+Function DefaultFindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PAnsiChar): TFPResourceHandle;
 begin
   Result:=0;
 end;
 
-Function DefaultFindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PChar; Language : word): TFPResourceHandle;
+Function DefaultFindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
 begin
   Result:=0;
 end;
@@ -179,23 +179,23 @@ begin
   Result:=resourcemanager.EnumResourceTypesFunc(ModuleHandle,EnumFunc,lParam);
 end;
 
-Function EnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
+Function EnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PAnsiChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
 begin
   Result:=resourcemanager.EnumResourceNamesFunc(ModuleHandle,ResourceType,EnumFunc,lParam);
 end;
 
-Function EnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
+Function EnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PAnsiChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
 begin
   Result:=resourcemanager.EnumResourceLanguagesFunc(ModuleHandle,ResourceType,ResourceName,EnumFunc,lParam);
 end;
 
 {$ifndef Win16}
-Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PChar): TFPResourceHandle;
+Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PAnsiChar): TFPResourceHandle;
 begin
   Result:=resourcemanager.FindResourceFunc(ModuleHandle,ResourceName,ResourceType);
 end;
 
-Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PChar; Language : word): TFPResourceHandle;
+Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PAnsiChar; Language : word): TFPResourceHandle;
 begin
   Result:=resourcemanager.FindResourceExFunc(ModuleHandle,ResourceType,ResourceName,Language);
 end;

+ 19 - 19
rtl/inc/system.inc

@@ -374,7 +374,7 @@ begin
 end;
 
 
-procedure fillchar(var x;count : {$ifdef FILLCHAR_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif};value : char);
+procedure fillchar(var x;count : {$ifdef FILLCHAR_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif};value : AnsiChar);
 begin
   fillchar(x,count,byte(value));
 end;
@@ -386,7 +386,7 @@ begin
 end;
 
 
-function IndexChar(Const buf;len:SizeInt;b:char):SizeInt;
+function IndexChar(Const buf;len:SizeInt;b:AnsiChar):SizeInt;
 begin
   IndexChar:=IndexByte(Buf,Len,byte(B));
 end;
@@ -661,7 +661,7 @@ type
     procedure Setup(const seed: uint64);
     function Next: uint32; inline; // inlined as it is actually internal and called only through xsr128_32_u32rand
   private
-    state: array[0 .. 3] of uint32;
+    state: array[0 .. 3] of longword;
   end;
 
   procedure Xoshiro128ss_32.Setup(const seed: uint64);
@@ -1562,21 +1562,21 @@ End;
 
 {$ifdef FPC_HAS_FEATURE_HEAP}
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
-function ArrayStringToPPchar(const S:Array of AnsiString;reserveentries:Longint):ppchar; // const ?
+function ArrayStringToPPchar(const S:Array of AnsiString;reserveentries:Longint):ppansichar; // const ?
 {$ifdef EXCLUDE_COMPLEX_PROCS}
 begin
   runerror(217);
 end;
 {$else EXCLUDE_COMPLEX_PROCS}
-// Extra allocate reserveentries pchar's at the beginning (default param=0 after 1.0.x ?)
+// Extra allocate reserveentries pansichar's at the beginning (default param=0 after 1.0.x ?)
 // Note: for internal use by skilled programmers only
 // if "s" goes out of scope in the parent procedure, the pointer is dangling.
 
-var p   : ppchar;
+var p   : ppansichar;
     i   : ObjpasInt;
 begin
   if High(s)<Low(s) Then Exit(NIL);
-  Getmem(p,sizeof(pchar)*(high(s)-low(s)+ReserveEntries+2));  // one more for NIL, one more
+  Getmem(p,sizeof(pansichar)*(high(s)-low(s)+ReserveEntries+2));  // one more for NIL, one more
                                               // for cmd
   if p=nil then
     begin
@@ -1586,31 +1586,31 @@ begin
       exit(NIL);
     end;
   for i:=low(s) to high(s) do
-     p[i+Reserveentries]:=pchar(s[i]);
+     p[i+Reserveentries]:=pansichar(s[i]);
   p[high(s)+1+Reserveentries]:=nil;
   ArrayStringToPPchar:=p;
 end;
 {$endif EXCLUDE_COMPLEX_PROCS}
 
 
-Function StringToPPChar(Var S:AnsiString;ReserveEntries:integer):ppchar;
+Function StringToPPChar(Var S:AnsiString;ReserveEntries:integer):ppansichar;
 {
-  Create a PPChar to structure of pchars which are the arguments specified
+  Create a PPAnsiChar to structure of pchars which are the arguments specified
   in the string S. Especially useful for creating an ArgV for Exec-calls
 }
 
 begin
-  StringToPPChar:=StringToPPChar(PChar(S),ReserveEntries);
+  StringToPPChar:=StringToPPChar(PAnsiChar(S),ReserveEntries);
 end;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
 
-Function StringToPPChar(S: PChar;ReserveEntries:integer):ppchar;
+Function StringToPPChar(S: PAnsiChar;ReserveEntries:integer):ppansichar;
 
 var
   i,nr  : ObjpasInt;
-  Buf : ^char;
-  p   : ppchar;
+  Buf : ^ansichar;
+  p   : ppansichar;
 
 begin
   buf:=s;
@@ -1634,7 +1634,7 @@ begin
            inc(buf);
        end;
    end;
-  getmem(p,(ReserveEntries+nr)*sizeof(pchar));
+  getmem(p,(ReserveEntries+nr)*sizeof(pansichar));
   StringToPPChar:=p;
   if p=nil then
    begin
@@ -1777,11 +1777,11 @@ end;
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
 { Allow slash and backslash as separators }
-procedure DoDirSeparators(var p: pchar; inplace: boolean = true);
+procedure DoDirSeparators(var p: pansichar; inplace: boolean = true);
 var
   i : ObjpasInt;
   len : sizeint;
-  newp : pchar;
+  newp : pansichar;
 begin
   len:=length(p);
   newp:=nil;
@@ -1836,7 +1836,7 @@ end;
 procedure DoDirSeparators(var ps:RawByteString);
 var
   i : ObjpasInt;
-  p : pchar;
+  p : pansichar;
   unique : boolean;
 begin
   unique:=false;
@@ -1846,7 +1846,7 @@ begin
         if not unique then
           begin
             uniquestring(ps);
-            p:=pchar(ps);
+            p:=pansichar(ps);
             unique:=true;
           end;
         p[i-1]:=DirectorySeparator;

+ 44 - 27
rtl/inc/systemh.inc

@@ -19,9 +19,15 @@
 ****************************************************************************}
 
 {$I-,Q-,H-,R-,V-}
+
 {$mode objfpc}
 {$modeswitch advancedrecords}
 
+{$IFDEF UNICODERTL}
+{$modeswitch unicodestrings}
+{ modeswitch typehelpers}
+{$ENDIF}
+
 { At least 3.0.0 is required }
 {$if FPC_FULLVERSION<30000}
   {$fatal You need at least FPC 3.0.0 to build this version of FPC}
@@ -538,17 +544,28 @@ Type
 {$endif}
 
 { Zero - terminated strings }
+
+{$IFDEF FPC_HAS_ANSICHAR_CHAR}
+// Compiler defines AnsiChar and WideChar, not AnsiChar
+{$IFDEF UNICODERTL}
+  Char = WideChar;
+{$ElSE}
+  Char = AnsiChar;
+{$ENDIF}
+
+{$ELSE}
+  // Compiler defines Char, we make AnsiChar an alias
+  AnsiChar = char;
+{$ENDIF}
+
   PChar               = ^Char;
   PPChar              = ^PChar;
   PPPChar             = ^PPChar;
 
-  { AnsiChar is equivalent of Char, so we need
-    to use type renamings }
-  TAnsiChar           = Char;
-  AnsiChar            = Char;
-  PAnsiChar           = PChar;
-  PPAnsiChar          = PPChar;
-  PPPAnsiChar         = PPPChar;
+  TAnsiChar           = AnsiChar;
+  PAnsiChar           = ^AnsiChar;
+  PPAnsiChar          = ^PAnsiChar;
+  PPPAnsiChar         = ^PPAnsiChar;
 
   UTF8Char = AnsiChar;
   PUTF8Char = PAnsiChar;
@@ -760,9 +777,9 @@ type
   TBoundArray = array of SizeInt;
 
 {$ifdef CPU16}
-  TPCharArray = packed array[0..(MaxSmallint div SizeOf(PChar))-1] of PChar;
+  TPCharArray = packed array[0..(MaxSmallint div SizeOf(PAnsiChar))-1] of PAnsiChar;
 {$else CPU16}
-  TPCharArray = packed array[0..(MaxLongint div SizeOf(PChar))-1] of PChar;
+  TPCharArray = packed array[0..(MaxLongint div SizeOf(PAnsiChar))-1] of PAnsiChar;
 {$endif CPU16}
   PPCharArray = ^TPCharArray;
 
@@ -839,7 +856,7 @@ var
 
 {$ifndef HAS_CMDLINE}
 {Value should be changed during system initialization as appropriate.}
-var CmdLine:Pchar=nil;
+var CmdLine:PAnsiChar=nil; // MVC: TODO ?
 {$endif}
 
 {$ifdef FPC_HAS_FEATURE_THREADING}
@@ -892,12 +909,12 @@ function StackTop: Pointer;
 Procedure Move(const source;var dest;count:{$ifdef MOVE_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif});
 Procedure FillChar(var x;count:{$ifdef FILLCHAR_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif};Value:Byte);
 Procedure FillChar(var x;count:{$ifdef FILLCHAR_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif};Value:Boolean);
-Procedure FillChar(var x;count:{$ifdef FILLCHAR_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif};Value:Char);
+Procedure FillChar(var x;count:{$ifdef FILLCHAR_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif};Value:AnsiChar);
 procedure FillByte(var x;count:{$ifdef FILLCHAR_HAS_SIZEUINT_COUNT}SizeUInt{$else}SizeInt{$endif};value:byte);
 Procedure FillWord(var x;count:SizeInt;Value:Word);
 procedure FillDWord(var x;count:SizeInt;value:DWord);
 procedure FillQWord(var x;count:SizeInt;value:QWord);
-function  IndexChar(const buf;len:SizeInt;b:char):SizeInt;
+function  IndexChar(const buf;len:SizeInt;b:ansichar):SizeInt;
 function  IndexByte(const buf;len:SizeInt;b:byte):SizeInt; {$if defined(cpui386)} inline; {$endif}
 function  Indexword(const buf;len:SizeInt;b:word):SizeInt; {$if defined(cpui386)} inline; {$endif}
 function  IndexDWord(const buf;len:SizeInt;b:DWord):SizeInt; {$if defined(cpui386)} inline; {$endif}
@@ -907,7 +924,7 @@ function  CompareByte(const buf1,buf2;len:SizeInt):SizeInt; {$if defined(cpui386
 function  CompareWord(const buf1,buf2;len:SizeInt):SizeInt; {$if defined(cpui386)} inline; {$endif}
 function  CompareDWord(const buf1,buf2;len:SizeInt):SizeInt; {$if defined(cpui386)} inline; {$endif}
 procedure MoveChar0(const buf1;var buf2;len:SizeInt);
-function  IndexChar0(const buf;len:SizeInt;b:char):SizeInt;
+function  IndexChar0(const buf;len:SizeInt;b:Ansichar):SizeInt;
 function  CompareChar0(const buf1,buf2;len:SizeInt):SizeInt;
 procedure Prefetch(const mem);[internproc:fpc_in_prefetch_var];
 procedure ReadBarrier;
@@ -1256,11 +1273,11 @@ Function  DSeg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function  SSeg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 {****************************************************************************
-                      PChar and String Handling
+                      PAnsiChar and String Handling
 ****************************************************************************}
 
-function StrPas(p:pchar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
-function StrLen(p:pchar):sizeint;external name 'FPC_PCHAR_LENGTH';
+function StrPas(p:PAnsiChar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
+function StrLen(p:PAnsiChar):sizeint;external name 'FPC_PCHAR_LENGTH';
 
 { result:
   <0: invalid sequence detected after processing "-result" bytes
@@ -1274,10 +1291,10 @@ function Utf8CodePointLen(P: PAnsiChar; MaxLookAhead: SizeInt; IncludeCombiningD
 {$ifdef VER3_0}
 Procedure Delete(var s:shortstring;index:SizeInt;count:SizeInt);
 Procedure Insert(const source:shortstring;var s:shortstring;index:SizeInt);
-Procedure Insert(source:Char;var s:shortstring;index:SizeInt);
+Procedure Insert(source:AnsiChar;var s:shortstring;index:SizeInt);
 {$endif VER3_0}
 Function  Pos(const substr:shortstring;const s:shortstring; Offset: Sizeint = 1):SizeInt;
-Function  Pos(C:Char;const s:shortstring; Offset: Sizeint = 1):SizeInt;
+Function  Pos(C:AnsiChar;const s:shortstring; Offset: Sizeint = 1):SizeInt;
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 Function  Pos(const Substr : ShortString; const Source : RawByteString; Offset: Sizeint = 1) : SizeInt;
 
@@ -1289,7 +1306,7 @@ Procedure SetString(out S : AnsiString; Buf : PAnsiChar; Len : SizeInt);
 Procedure SetString(out S : AnsiString; Buf : PWideChar; Len : SizeInt);
 {$endif}
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
-Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_shortstr{$else}SetString{$endif}(out S : Shortstring; Buf : PChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
+Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_shortstr{$else}SetString{$endif}(out S : Shortstring; Buf : PAnsiChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
 function  ShortCompareText(const S1, S2: shortstring): SizeInt;
 Function  UpCase(const s:shortstring):shortstring;
 Function  LowerCase(const s:shortstring):shortstring; overload;
@@ -1317,13 +1334,13 @@ Function  HexStr(Val:HugePointer):shortstring;{$ifdef SYSTEMINLINE}inline;{$endi
 Function  HexStr(Val:Pointer):shortstring;
 {$endif CPUI8086}
 
-{ Char functions }
+{ AnsiChar functions }
 {$if defined(VER3_2) or defined(VER3_0)}
-Function Chr(b : byte) : Char;      [INTERNPROC: fpc_in_chr_byte];
+Function Chr(b : byte) : AnsiChar;      [INTERNPROC: fpc_in_chr_byte];
 {$endif defined(VER3_2) or defined(VER3_0)}
-Function  UpCase(c:Char):Char;
-Function  LowerCase(c:Char):Char; overload;
-function  Pos(const substr : shortstring;c:char; Offset: Sizeint = 1): SizeInt;
+Function  UpCase(c:AnsiChar):AnsiChar;
+Function  LowerCase(c:AnsiChar):AnsiChar; overload;
+function  Pos(const substr : shortstring;c:Ansichar; Offset: Sizeint = 1): SizeInt;
 
 
 {****************************************************************************
@@ -1738,10 +1755,10 @@ Procedure SysInitFPU;
 
 {$ifdef FPC_HAS_FEATURE_HEAP}
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
-function ArrayStringToPPchar(const S:Array of AnsiString;reserveentries:Longint):ppchar; // const ?
-Function StringToPPChar(var S:AnsiString;ReserveEntries:integer):ppchar;
+function ArrayStringToPPchar(const S:Array of AnsiString;reserveentries:Longint):ppansichar; // const ?
+Function StringToPPChar(var S:AnsiString;ReserveEntries:integer):ppansichar;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
-Function StringToPPChar(S: PChar;ReserveEntries:integer):ppchar;
+Function StringToPPChar(S: PAnsiChar;ReserveEntries:integer):ppansichar;
 {$endif FPC_HAS_FEATURE_HEAP}
 
 

+ 94 - 89
rtl/inc/text.inc

@@ -114,7 +114,7 @@ begin
     UnicodeString(TextRec(t).FullName):=S;
 {$endif USE_FILEREC_FULLNAME}
 {$endif FPC_ANSI_TEXTFILEREC}
-  { null terminate, since the name array is regularly used as p(wide)char }
+  { null terminate, since the name array is regularly used as p(wide)AnsiChar }
   TextRec(t).Name[high(TextRec(t).Name)]:=#0;
 end;
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
@@ -138,7 +138,7 @@ Begin
     UnicodeString(TextRec(t).FullName):=S;
 {$endif USE_FILEREC_FULLNAME}
 {$endif FPC_ANSI_TEXTFILEREC}
-  { null terminate, since the name array is regularly used as p(wide)char }
+  { null terminate, since the name array is regularly used as p(wide)AnsiChar }
   TextRec(t).Name[high(TextRec(t).Name)]:=#0;
 End;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
@@ -152,7 +152,7 @@ Begin
   InitText(t);
   { warning: no encoding support }
   TextRec(t).Name:=s;
-  { null terminate, since the name array is regularly used as p(wide)char }
+  { null terminate, since the name array is regularly used as p(wide)AnsiChar }
   TextRec(t).Name[high(TextRec(t).Name)]:=#0;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 End;
@@ -389,11 +389,11 @@ Begin
 End;
 {$else FPC_HAS_FEATURE_ANSISTRINGS}
 var
-  p : array[0..255] Of Char;
+  p : array[0..255] Of AnsiChar;
 Begin
   Move(s[1],p,Length(s));
   p[Length(s)]:=#0;
-  Rename(t,Pchar(@p));
+  Rename(t,PAnsiChar(@p));
 End;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
@@ -591,7 +591,7 @@ Begin
   TextRec(f).BufEnd:=0;
 End;
 
-Procedure SetTextLineEnding(Var f:Text; Ending:string);
+Procedure SetTextLineEnding(Var f:Text; Ending: string);
 Begin
   TextRec(F).LineEnd:=Ending;
 End;
@@ -675,7 +675,7 @@ begin
 end;
 
 
-Procedure fpc_textinit_filename_iso(var t : Text;nr : DWord;const filename : string);compilerproc;
+Procedure fpc_textinit_filename_iso(var t : Text;nr : DWord;const filename : shortstring);compilerproc;
 begin
 {$ifdef FPC_HAS_FEATURE_COMMANDARGS}
   if paramstr(nr)='' then
@@ -708,11 +708,11 @@ end;
 
 Procedure fpc_WriteBuffer(var f:Text;const b;len:SizeInt);
 var
-  p   : pchar;
+  p   : pansichar;
   left,
   idx : SizeInt;
 begin
-  p:=pchar(@b);
+  p:=pansichar(@b);
   idx:=0;
   left:=TextRec(f).BufSize-TextRec(f).BufPos;
   while len>left do
@@ -772,7 +772,7 @@ begin
 end;
 
 
-Procedure fpc_Write_Text_ShortStr(Len : Longint;var f : Text;const s : String); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SHORTSTR']; compilerproc;
+Procedure fpc_Write_Text_ShortStr(Len : Longint;var f : Text;const s : ShortString); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SHORTSTR']; compilerproc;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -789,7 +789,7 @@ Begin
 End;
 
 
-Procedure fpc_Write_Text_ShortStr_Iso(Len : Longint;var f : Text;const s : String); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SHORTSTR_ISO']; compilerproc;
+Procedure fpc_Write_Text_ShortStr_Iso(Len : Longint;var f : Text;const s : ShortString); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SHORTSTR_ISO']; compilerproc;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -815,22 +815,22 @@ End;
 
 
 { provide local access to write_str }
-procedure Write_Str(Len : Longint;var f : Text;const s : String); iocheck; [external name 'FPC_WRITE_TEXT_SHORTSTR'];
+procedure Write_Str(Len : Longint;var f : Text;const s : ShortString); iocheck; [external name 'FPC_WRITE_TEXT_SHORTSTR'];
 
 { provide local access to write_str_iso }
-procedure Write_Str_Iso(Len : Longint;var f : Text;const s : String); iocheck; [external name 'FPC_WRITE_TEXT_SHORTSTR_ISO'];
+procedure Write_Str_Iso(Len : Longint;var f : Text;const s : ShortString); iocheck; [external name 'FPC_WRITE_TEXT_SHORTSTR_ISO'];
 
-Procedure fpc_Write_Text_Pchar_as_Array(Len : Longint;var f : Text;const s : array of char; zerobased: boolean = true); iocheck; compilerproc;
+Procedure fpc_Write_Text_Pchar_as_Array(Len : Longint;var f : Text;const s : array of ansichar; zerobased: boolean = true); iocheck; compilerproc;
 var
   ArrayLen : longint;
-  p : pchar;
+  p : pansichar;
 Begin
   If (InOutRes<>0) then
    exit;
   case TextRec(f).mode of
     fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
       begin
-        p:=pchar(@s);
+        p:=pansichar(@s);
         if zerobased then
           begin
             { can't use StrLen, since that one could try to read past the end }
@@ -852,17 +852,17 @@ Begin
 End;
 
 
-Procedure fpc_Write_Text_Pchar_as_Array_Iso(Len : Longint;var f : Text;const s : array of char; zerobased: boolean = true); iocheck; compilerproc;
+Procedure fpc_Write_Text_Pchar_as_Array_Iso(Len : Longint;var f : Text;const s : array of ansichar; zerobased: boolean = true); iocheck; compilerproc;
 var
   ArrayLen : longint;
-  p : pchar;
+  p : pansichar;
 Begin
   If (InOutRes<>0) then
    exit;
   case TextRec(f).mode of
     fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
       begin
-        p:=pchar(@s);
+        p:=pansichar(@s);
         if zerobased then
           begin
             { can't use StrLen, since that one could try to read past the end }
@@ -893,7 +893,7 @@ Begin
 End;
 
 
-Procedure fpc_Write_Text_PChar_As_Pointer(Len : Longint;var f : Text;p : PChar); iocheck; compilerproc;
+Procedure fpc_Write_Text_PChar_As_Pointer(Len : Longint;var f : Text;p : PAnsiChar); iocheck; compilerproc;
 var
   PCharLen : longint;
 Begin
@@ -1013,7 +1013,7 @@ end;
 
 Procedure fpc_Write_Text_SInt(Len : Longint;var t : Text;l : ValSInt); iocheck; compilerproc;
 var
-  s : String;
+  s : ShortString;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -1024,7 +1024,7 @@ End;
 
 Procedure fpc_Write_Text_UInt(Len : Longint;var t : Text;l : ValUInt); iocheck; compilerproc;
 var
-  s : String;
+  s : ShortString;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -1035,7 +1035,7 @@ End;
 
 Procedure fpc_Write_Text_SInt_Iso(Len : Longint;var t : Text;l : ValSInt); iocheck; compilerproc;
 var
-  s : String;
+  s : ShortString;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -1123,7 +1123,7 @@ end;
 {$if defined(CPU16) or defined(CPU8)}
 procedure fpc_write_text_longword(len : longint;var t : text;q : longword); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
    exit;
@@ -1134,7 +1134,7 @@ end;
 
 procedure fpc_write_text_longint(len : longint;var t : text;i : longint); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
    exit;
@@ -1145,7 +1145,7 @@ end;
 
 procedure fpc_write_text_longword_iso(len : longint;var t : text;q : longword); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
     exit;
@@ -1161,7 +1161,7 @@ end;
 
 procedure fpc_write_text_longint_iso(len : longint;var t : text;i : longint); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
    exit;
@@ -1177,7 +1177,7 @@ end;
 
 procedure fpc_write_text_word(len : longint;var t : text;q : word); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
    exit;
@@ -1188,7 +1188,7 @@ end;
 
 procedure fpc_write_text_smallint(len : longint;var t : text;i : smallint); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
    exit;
@@ -1199,7 +1199,7 @@ end;
 
 procedure fpc_write_text_word_iso(len : longint;var t : text;q : word); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
     exit;
@@ -1215,7 +1215,7 @@ end;
 
 procedure fpc_write_text_smallint_iso(len : longint;var t : text;i : smallint); iocheck; compilerproc;
 var
-  s : string;
+  s : shortstring;
 begin
   if (InOutRes<>0) then
    exit;
@@ -1232,7 +1232,7 @@ end;
 {$ifndef FPUNONE}
 Procedure fpc_Write_Text_Float(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); iocheck; compilerproc;
 var
-  s : String;
+  s : shortString;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -1243,7 +1243,7 @@ End;
 
 Procedure fpc_Write_Text_Float_iso(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); iocheck; compilerproc;
 var
-  s : String;
+  s : shortString;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -1255,7 +1255,7 @@ End;
 procedure fpc_write_text_enum(typinfo,ord2strindex:pointer;len:sizeint;var t:text;ordinal:longint); iocheck; compilerproc;
 
 var
-    s:string;
+    s:shortstring;
 
 begin
 {$ifdef EXCLUDE_COMPLEX_PROCS}
@@ -1283,7 +1283,7 @@ Procedure fpc_Write_Text_Currency(fixkomma,Len : Longint;var t : Text;c : Curren
       end;
 {$else EXCLUDE_COMPLEX_PROCS}
 var
-  s : String;
+  s : shortstring;
 Begin
   If (InOutRes<>0) then
    exit;
@@ -1319,7 +1319,7 @@ Begin
 End;
 
 
-Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); iocheck; compilerproc;
+Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : AnsiChar); iocheck; compilerproc;
 Begin
   If (InOutRes<>0) then
     exit;
@@ -1340,7 +1340,7 @@ Begin
 End;
 
 
-Procedure fpc_Write_Text_Char_Iso(Len : Longint;var t : Text;c : Char); iocheck; compilerproc;
+Procedure fpc_Write_Text_Char_Iso(Len : Longint;var t : Text;c : AnsiChar); iocheck; compilerproc;
 Begin
   If (InOutRes<>0) then
     exit;
@@ -1400,7 +1400,7 @@ End;
                                 Read(Ln)
 *****************************************************************************}
 
-Function NextChar(var f:Text;var s:string):Boolean;
+Function NextChar(var f:Text;var s:shortstring):Boolean;
 begin
   NextChar:=false;
   if (TextRec(f).BufPos<TextRec(f).BufEnd) then
@@ -1408,7 +1408,7 @@ begin
     begin
      if length(s)<high(s) then
       begin
-        inc(s[0]);
+        SetLength(s,Length(s)+1);
         s[length(s)]:=TextRec(f).BufPtr^[TextRec(f).BufPos];
       end;
      Inc(TextRec(f).BufPos);
@@ -1425,7 +1425,7 @@ Function IgnoreSpaces(var f:Text):Boolean;
   the buffer is empty
 }
 var
-  s : string;
+  s : shortstring;
 begin
   s:='';
   IgnoreSpaces:=false;
@@ -1449,7 +1449,7 @@ begin
 end;
 
 
-procedure ReadNumeric(var f:Text;var s:string);
+procedure ReadNumeric(var f:Text;var s:shortstring);
 {
   Read numeric input, if buffer is empty then return True
 }
@@ -1483,7 +1483,7 @@ begin
 end;
 
 
-procedure ReadInteger(var f:Text;var s:string);
+procedure ReadInteger(var f:Text;var s:shortstring);
 {
  Ignore leading blanks (incl. EOF) and return the first characters matching
  an integer in the format recognized by the Val procedure:
@@ -1541,7 +1541,7 @@ begin
 end;
 
 
-procedure ReadReal(var f:Text;var s:string);
+procedure ReadReal(var f:Text;var s:shortstring);
 {
  Ignore leading blanks (incl. EOF) and return the first characters matching
  a float number in the format recognized by the Val procedure:
@@ -1615,7 +1615,7 @@ end;
 
 
 Procedure fpc_ReadLn_End(var f : Text);[Public,Alias:'FPC_READLN_END']; iocheck; compilerproc;
-var prev: char;
+var prev: AnsiChar;
 Begin
   If not CheckRead(f) then
     exit;
@@ -1667,7 +1667,7 @@ End;
 
 
 Procedure fpc_ReadLn_End_Iso(var f : Text);[Public,Alias:'FPC_READLN_END_ISO']; iocheck; compilerproc;
-var prev: char;
+var prev: AnsiChar;
 Begin
   If not CheckRead(f) then
     exit;
@@ -1724,10 +1724,10 @@ Begin
 End;
 
 
-Function ReadPCharLen(var f:Text;s:pchar;maxlen:longint):longint;
+Function ReadPCharLen(var f:Text;s:pansichar;maxlen:longint):longint;
 var
   sPos,len : Longint;
-  p,startp,maxp : pchar;
+  p,startp,maxp : pansichar;
   end_of_string:boolean;
 Begin
 {$ifdef EXCLUDE_COMPLEX_PROCS}
@@ -1778,23 +1778,28 @@ Begin
 End;
 
 
-Procedure fpc_Read_Text_ShortStr(var f : Text;out s : String); iocheck; compilerproc;
+Procedure fpc_Read_Text_ShortStr(var f : Text;out s : ShortString); iocheck; compilerproc;
+
+var
+  Len : Longint;
+
 Begin
-  s[0]:=chr(ReadPCharLen(f,pchar(@s[1]),high(s)));
+  Len:=ReadPCharLen(f,pansichar(@s[1]),high(s));
+  SetLength(S,Len);
 End;
 
 
-Procedure fpc_Read_Text_PChar_As_Pointer(var f : Text; const s : PChar); iocheck; compilerproc;
+Procedure fpc_Read_Text_PChar_As_Pointer(var f : Text; const s : PAnsiChar); iocheck; compilerproc;
 Begin
-  pchar(s+ReadPCharLen(f,s,$7fffffff))^:=#0;
+  pansichar(s+ReadPCharLen(f,s,$7fffffff))^:=#0;
 End;
 
 
-Procedure fpc_Read_Text_PChar_As_Array(var f : Text;out s : array of char; zerobased: boolean = false); iocheck; compilerproc;
+Procedure fpc_Read_Text_PChar_As_Array(var f : Text;out s : array of ansichar; zerobased: boolean = false); iocheck; compilerproc;
 var
   len: longint;
 Begin
-  len := ReadPCharLen(f,pchar(@s),high(s)+1);
+  len := ReadPCharLen(f,pansichar(@s),high(s)+1);
   if zerobased and
      (len > high(s)) then
     len := high(s);
@@ -1812,7 +1817,7 @@ Begin
   Repeat
     // SetLength will reallocate the length.
     SetLength(s,slen+255);
-    len:=ReadPCharLen(f,pchar(Pointer(s)+slen),255);
+    len:=ReadPCharLen(f,pansichar(Pointer(s)+slen),255);
     inc(slen,len);
   Until len<255;
   // Set actual length
@@ -1861,7 +1866,7 @@ Begin
 End;
 {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
 
-procedure fpc_Read_Text_Char(var f : Text; out c: char); [public, alias: 'FPC_READ_TEXT_CHAR']; iocheck; compilerproc;
+procedure fpc_Read_Text_Char(var f : Text; out c: AnsiChar); [public, alias: 'FPC_READ_TEXT_CHAR']; iocheck; compilerproc;
 Begin
   c:=#0;
   If not CheckRead(f) then
@@ -1875,10 +1880,10 @@ Begin
   inc(TextRec(f).BufPos);
 end;
 
-procedure fpc_Read_Text_Char_intern(var f : Text; out c: char); iocheck; [external name 'FPC_READ_TEXT_CHAR'];
+procedure fpc_Read_Text_Char_intern(var f : Text; out c: AnsiChar); iocheck; [external name 'FPC_READ_TEXT_CHAR'];
 
 
-function fpc_GetBuf_Text(var f : Text) : pchar; iocheck; compilerproc;
+function fpc_GetBuf_Text(var f : Text) : pansichar; iocheck; compilerproc;
 Begin
   Result:=@TextRec(f).Bufptr^[TextRec(f).BufEnd];
   if TextRec(f).mode=fmOutput then
@@ -1897,7 +1902,7 @@ var
   ws: widestring;
   i: longint;
   { maximum code point length is 6 characters (with UTF-8) }
-  str: array[0..5] of char;
+  str: array[0..5] of AnsiChar;
 Begin
   fillchar(str[0],sizeof(str),0);
   for i:=low(str) to high(str) do
@@ -1936,7 +1941,7 @@ end;
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
 
 
-procedure fpc_Read_Text_Char_Iso(var f : Text; out c: char); iocheck;compilerproc;
+procedure fpc_Read_Text_Char_Iso(var f : Text; out c: AnsiChar); iocheck;compilerproc;
 Begin
   c:=' ';
   If not CheckRead(f) then
@@ -1981,7 +1986,7 @@ end;
 
 Procedure fpc_Read_Text_SInt(var f : Text; out l : ValSInt); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : ValSInt;
 Begin
   l:=0;
@@ -2011,7 +2016,7 @@ End;
 
 Procedure fpc_Read_Text_SInt_Iso(var f : Text; out l : ValSInt); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : ValSInt;
 Begin
   l:=0;
@@ -2028,7 +2033,7 @@ End;
 
 Procedure fpc_Read_Text_UInt(var f : Text; out u : ValUInt);  iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : ValSInt;
 Begin
   u:=0;
@@ -2055,7 +2060,7 @@ End;
 
 Procedure fpc_Read_Text_UInt_Iso(var f : Text; out u : ValUInt);  iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : ValSInt;
 Begin
   u:=0;
@@ -2072,7 +2077,7 @@ End;
 {$ifndef FPUNONE}
 procedure fpc_Read_Text_Float(var f : Text; out v : ValReal); iocheck; compilerproc;
 var
-  hs : string;
+  hs : shortstring;
   code : Word;
 begin
   v:=0.0;
@@ -2095,7 +2100,7 @@ end;
 
 procedure fpc_Read_Text_Float_Iso(var f : Text; out v : ValReal); iocheck; compilerproc;
 var
-  hs : string;
+  hs : shortstring;
   code : Word;
 begin
   v:=0.0;
@@ -2115,7 +2120,7 @@ procedure fpc_read_text_enum(str2ordindex:pointer;var t:text;out ordinal:longint
 procedure fpc_read_text_enum_longint(str2ordindex:pointer;var t:text;out ordinal:longint); iocheck;compilerproc;
 {$endif VER3_2}
 
-var s:string;
+var s:shortstring;
     code:valsint;
 
 begin
@@ -2137,7 +2142,7 @@ end;
 {$ifndef VER3_2}
 procedure fpc_read_text_enum_smallint(str2ordindex:pointer;var t:text;out ordinal:smallint); iocheck;compilerproc;
 
-var s:string;
+var s:shortstring;
     code:valsint;
 
 begin
@@ -2158,7 +2163,7 @@ end;
 
 procedure fpc_read_text_enum_shortint(str2ordindex:pointer;var t:text;out ordinal:shortint); iocheck;compilerproc;
 
-var s:string;
+var s:shortstring;
     code:valsint;
 
 begin
@@ -2180,7 +2185,7 @@ end;
 
 procedure fpc_Read_Text_Currency(var f : Text; out v : Currency); iocheck; compilerproc;
 var
-  hs : string;
+  hs : shortstring;
   code : ValSInt;
 begin
 {$ifdef FPUNONE}
@@ -2207,7 +2212,7 @@ end;
 
 procedure fpc_Read_Text_Currency_Iso(var f : Text; out v : Currency); iocheck; compilerproc;
 var
-  hs : string;
+  hs : shortstring;
   code : ValSInt;
 begin
   v:=0;
@@ -2225,7 +2230,7 @@ end;
 
 procedure fpc_Read_Text_QWord(var f : text; out q : qword); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : longint;
 Begin
   q:=0;
@@ -2247,7 +2252,7 @@ End;
 
 procedure fpc_Read_Text_QWord_Iso(var f : text; out q : qword); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : longint;
 Begin
   q:=0;
@@ -2262,7 +2267,7 @@ End;
 
 procedure fpc_Read_Text_Int64(var f : text; out i : int64); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : Longint;
 Begin
   i:=0;
@@ -2284,7 +2289,7 @@ End;
 
 procedure fpc_Read_Text_Int64_Iso(var f : text; out i : int64); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : Longint;
 Begin
   i:=0;
@@ -2303,7 +2308,7 @@ End;
 {$if defined(CPU16) or defined(CPU8)}
 procedure fpc_Read_Text_LongWord(var f : text; out q : longword); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : longint;
 Begin
   q:=0;
@@ -2325,7 +2330,7 @@ End;
 
 procedure fpc_Read_Text_LongInt(var f : text; out i : longint); iocheck; compilerproc;
 var
-  hs   : String;
+  hs   : shortstring;
   code : Longint;
 Begin
   i:=0;
@@ -2353,13 +2358,13 @@ End;
 *****************************************************************************}
 
 const
-  { pointer to target string }
+  { pointer to target shortstring }
   StrPtrIndex = 1;
   { temporary destination for writerstr, because the original value of the
     destination may be used in the writestr expression }
   TempWriteStrDestIndex = 9;
   ShortStrLenIndex = 17;
-  { how many bytes of the string have been processed already (used for readstr) }
+  { how many bytes of the shortstring have been processed already (used for readstr) }
   BytesReadIndex = 17;
 
 procedure WriteStrShort(var t: textrec);
@@ -2379,7 +2384,7 @@ begin
 {$ifdef writestr_iolencheck}
       // GPC only gives an io error if {$no-truncate-strings} is active
       // FPC does not have this setting (it never gives errors when a
-      // a string expression is truncated)
+      // a shortstring expression is truncated)
 
       { "disk full" }
       inoutres:=101;
@@ -2393,12 +2398,12 @@ end;
 
 procedure WriteStrShortFlush(var t: textrec);
 begin
-  { move written data from internal buffer to temporary string (don't move
-    directly from buffer to final string, because the temporary string may
-    already contain data in case the textbuf was smaller than the string
+  { move written data from internal buffer to temporary shortstring (don't move
+    directly from buffer to final shortstring, because the temporary shortstring may
+    already contain data in case the textbuf was smaller than the shortstring
     length) }
   WriteStrShort(t);
-  { move written data to original string }
+  { move written data to original shortstring }
   move(PPointer(@t.userdata[TempWriteStrDestIndex])^^,
        PPointer(@t.userdata[StrPtrIndex])^^,
        t.userdata[ShortStrLenIndex]+1);
@@ -2446,7 +2451,7 @@ begin
       { we don't care about combining diacritical marks here: we just want a
         valid UTF-8 codepoint that we can translate to UTF-16. The combining
         diacritical marks can be translated separately }
-      codepointlen:=Utf8CodePointLen(pchar(@t.bufptr^[i]),(t.bufpos-1-i)+1,false);
+      codepointlen:=Utf8CodePointLen(pansichar(@t.bufptr^[i]),(t.bufpos-1-i)+1,false);
       { complete codepoint -> flush till here }
       if codepointlen>0 then
         begin
@@ -2577,7 +2582,7 @@ begin
   SetupWriteStrCommon(TextRec(ReadWriteStrText),cp);
   PPointer(@TextRec(ReadWriteStrText).userdata[StrPtrIndex])^:=@s;
 
-  { temp destination ansistring, nil = empty string }
+  { temp destination ansistring, nil = empty shortstring }
   PPointer(@TextRec(ReadWriteStrText).userdata[TempWriteStrDestIndex])^:=nil;
 
   TextRec(ReadWriteStrText).InOutFunc:=@WriteStrAnsi;
@@ -2592,7 +2597,7 @@ begin
   SetupWriteStrCommon(TextRec(ReadWriteStrText),CP_UTF8);
   PPointer(@TextRec(ReadWriteStrText).userdata[StrPtrIndex])^:=@s;
 
-  { temp destination unicodestring, nil = empty string }
+  { temp destination unicodestring, nil = empty shortstring }
   PPointer(@TextRec(ReadWriteStrText).userdata[TempWriteStrDestIndex])^:=nil;
 
   TextRec(ReadWriteStrText).InOutFunc:=@WriteStrUnicode;
@@ -2625,7 +2630,7 @@ end;
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 
 
-procedure ReadStrCommon(var t: textrec; strdata: pchar; len: sizeint);
+procedure ReadStrCommon(var t: textrec; strdata: pansichar; len: sizeint);
 var
   newbytes: sizeint;
 begin
@@ -2688,8 +2693,8 @@ begin
     *********************
     Apart from the restrictions imposed by requirements given in this clause,
     the execution of readstr(e,v 1 ,...,v n ) where e denotes a
-    string-expression and v 1 ,...,v n denote variable-accesses possessing the
-    char-type (or a subrange of char-type), the integer-type (or a subrange of
+    shortstring-expression and v 1 ,...,v n denote variable-accesses possessing the
+    AnsiChar-type (or a subrange of AnsiChar-type), the integer-type (or a subrange of
     integer-type), the real-type, a fixed-string-type, or a
     variable-string-type, shall be equivalent to
 

+ 3 - 3
rtl/inc/threadvr.inc

@@ -44,7 +44,7 @@ begin
   while tableEntry^.varaddr <> nil do
    begin
      CurrentTM.InitThreadvar (tableEntry^.varaddr^, tableEntry^.size);
-     inc (pchar (tableEntry), sizeof (tableEntry^));
+     inc (pansichar (tableEntry), sizeof (tableEntry^));
    end;
 end;
 
@@ -76,9 +76,9 @@ begin
   while tableEntry^.varaddr <> nil do
    begin
      newp:=CurrentTM.RelocateThreadVar(tableEntry^.varaddr^);
-     oldp:=pointer(pchar(tableEntry^.varaddr)+sizeof(pointer));
+     oldp:=pointer(pansichar(tableEntry^.varaddr)+sizeof(pointer));
      move(oldp^,newp^,tableEntry^.size);
-     inc (pchar (tableEntry), sizeof (tableEntry^));
+     inc (pansichar (tableEntry), sizeof (tableEntry^));
    end;
 end;
 

+ 18 - 18
rtl/inc/ustringh.inc

@@ -17,7 +17,7 @@
 
 Procedure UniqueString (Var S : UnicodeString);{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (Const Substr : UnicodeString; Const Source : UnicodeString; Offset: Sizeint = 1) : SizeInt;
-Function Pos (c : Char; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
+Function Pos (c : AnsiChar; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
 Function Pos (c : UnicodeChar; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
 Function Pos (const c : RawByteString; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
 Function Pos (const c : UnicodeString; Const s : RawByteString; Offset: Sizeint = 1) : SizeInt;
@@ -33,7 +33,7 @@ Procedure Insert (Const Source : UnicodeString; Var S : UnicodeString; Index : S
 Procedure Delete (Var S : UnicodeString; Index,Size: SizeInt);
 {$endif VER3_0}
 Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_unicodestr_pwidechar{$else}SetString{$endif}(Out S : UnicodeString; Buf : PUnicodeChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
-Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_unicodestr_pansichar{$else}SetString{$endif}(Out S : UnicodeString; Buf : PChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
+Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_unicodestr_pansichar{$else}SetString{$endif}(Out S : UnicodeString; Buf : PAnsiChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
 
 function WideCharToString(S : PWideChar) : UnicodeString;
 function StringToWideChar(const Src : RawByteString;Dest : PWideChar;DestSize : SizeInt) : PWideChar;
@@ -51,7 +51,7 @@ procedure UnicodeCharLenToStrVar(Src : PUnicodeChar;Len : SizeInt;out Dest : Ans
 procedure UnicodeCharToStrVar(S : PUnicodeChar;out Dest : AnsiString);
 
 procedure DefaultUnicode2AnsiMove(source:punicodechar;var dest:RawByteString;cp : TSystemCodePage;len:SizeInt);
-procedure DefaultAnsi2UnicodeMove(source:pchar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
+procedure DefaultAnsi2UnicodeMove(source:pansichar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
 
 Type
   { please only enable options below after creating a test program for them that
@@ -73,7 +73,7 @@ Type
     please add new procedures at the end, it makes it easier to detect new procedures }
   TUnicodeStringManager = record
     Wide2AnsiMoveProc : procedure(source:pwidechar;var dest:RawByteString;cp : TSystemCodePage;len:SizeInt);
-    Ansi2WideMoveProc : procedure(source:pchar;cp : TSystemCodePage;var dest:widestring;len:SizeInt);
+    Ansi2WideMoveProc : procedure(source:pansichar;cp : TSystemCodePage;var dest:widestring;len:SizeInt);
 
 //    UpperUTF8 : procedure(p:PUTF8String);
 
@@ -94,29 +94,29 @@ Type
       code point is encountered, all characters part of this invalid code point
       are considered to form one "character" and the next character is
       considered to be the start of a new (possibly also invalid) code point }
-    CharLengthPCharProc : function(const Str: PChar): PtrInt;
+    CharLengthPCharProc : function(const Str: PAnsiChar): PtrInt;
     { return value:
       -1 if incomplete or invalid code point
       0 if NULL character,
       > 0 if that's the length in bytes of the code point }
-    CodePointLengthProc : function(const Str: PChar; MaxLookAead: PtrInt): Ptrint;
+    CodePointLengthProc : function(const Str: PAnsiChar; MaxLookAead: PtrInt): Ptrint;
 
     UpperAnsiStringProc : function(const s : ansistring) : ansistring;
     LowerAnsiStringProc : function(const s : ansistring) : ansistring;
     CompareStrAnsiStringProc : function(const S1, S2: ansistring): PtrInt;
     CompareTextAnsiStringProc : function(const S1, S2: ansistring): PtrInt;
-    StrCompAnsiStringProc : function(S1, S2: PChar): PtrInt;
-    StrICompAnsiStringProc : function(S1, S2: PChar): PtrInt;
-    StrLCompAnsiStringProc : function(S1, S2: PChar; MaxLen: PtrUInt): PtrInt;
-    StrLICompAnsiStringProc : function(S1, S2: PChar; MaxLen: PtrUInt): PtrInt;
-    StrLowerAnsiStringProc : function(Str: PChar): PChar;
-    StrUpperAnsiStringProc : function(Str: PChar): PChar;
+    StrCompAnsiStringProc : function(S1, S2: PAnsiChar): PtrInt;
+    StrICompAnsiStringProc : function(S1, S2: PAnsiChar): PtrInt;
+    StrLCompAnsiStringProc : function(S1, S2: PAnsiChar; MaxLen: PtrUInt): PtrInt;
+    StrLICompAnsiStringProc : function(S1, S2: PAnsiChar; MaxLen: PtrUInt): PtrInt;
+    StrLowerAnsiStringProc : function(Str: PAnsiChar): PAnsiChar;
+    StrUpperAnsiStringProc : function(Str: PAnsiChar): PAnsiChar;
     ThreadInitProc : procedure;
     ThreadFiniProc : procedure;
 
     { this is only different on windows }
     Unicode2AnsiMoveProc : procedure(source:punicodechar;var dest:RawByteString;cp : TSystemCodePage;len:SizeInt);
-    Ansi2UnicodeMoveProc : procedure(source:pchar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
+    Ansi2UnicodeMoveProc : procedure(source:pansichar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
     UpperUnicodeStringProc : function(const S: UnicodeString): UnicodeString;
     LowerUnicodeStringProc : function(const S: UnicodeString): UnicodeString;
     CompareUnicodeStringProc : function(const s1, s2 : UnicodeString; Options : TCompareOptions) : PtrInt;
@@ -131,11 +131,11 @@ Type
 var
   widestringmanager : TUnicodeStringManager;
 
-function UnicodeToUtf8(Dest: PChar; Source: PUnicodeChar; MaxBytes: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
-function UnicodeToUtf8(Dest: PChar; MaxDestBytes: SizeUInt; Source: PUnicodeChar; SourceChars: SizeUInt): SizeUInt;
-function Utf8ToUnicode(Dest: PUnicodeChar; Source: PChar; MaxChars: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PChar; SourceBytes: SizeUInt): SizeUInt;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PChar; SourceBytes: SizeUInt; IgnoreInvalid : Boolean): SizeUInt;
+function UnicodeToUtf8(Dest: PAnsiChar; Source: PUnicodeChar; MaxBytes: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+function UnicodeToUtf8(Dest: PAnsiChar; MaxDestBytes: SizeUInt; Source: PUnicodeChar; SourceChars: SizeUInt): SizeUInt;
+function Utf8ToUnicode(Dest: PUnicodeChar; Source: PAnsiChar; MaxChars: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PAnsiChar; SourceBytes: SizeUInt): SizeUInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PAnsiChar; SourceBytes: SizeUInt; IgnoreInvalid : Boolean): SizeUInt;
 function UTF8Encode(const s : RawByteString) : RawByteString; inline;
 function UTF8Encode(const s : UnicodeString) : RawByteString;
 function UTF8Decode(const s : RawByteString): UnicodeString;

+ 45 - 45
rtl/inc/ustrings.inc

@@ -60,7 +60,7 @@ Const
 {$endif FPC_UNICODESTRING_TYPE_DEFINED}
 
 {
-  Default UnicodeChar <-> Char conversion is to only convert the
+  Default UnicodeChar <-> AnsiChar conversion is to only convert the
   lower 127 chars, all others are translated to '?'.
 
   These routines can be overridden for the Current Locale
@@ -81,7 +81,7 @@ begin
   for i:=1 to len do
     begin
       if word(source^)<256 then
-        p^:=char(word(source^))
+        p^:=AnsiChar(word(source^))
       else
         p^:='?';
       inc(source);
@@ -93,7 +93,7 @@ end;
 
 {$ifndef FPC_HAS_DEFAULT_ANSI_2_UNICODE}
 {$define FPC_HAS_DEFAULT_ANSI_2_UNICODE}
-procedure DefaultAnsi2UnicodeMove(source:pchar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
+procedure DefaultAnsi2UnicodeMove(source:pansichar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
 var
   i : SizeInt;
   p : PUnicodeChar;
@@ -111,13 +111,13 @@ end;
 
 
 {$ifndef FPC_HAS_BUILTIN_WIDESTR_MANAGER}
-function DefaultCharLengthPChar(const Str: PChar): PtrInt;
+function DefaultCharLengthPChar(const Str: PAnsiChar): PtrInt;
   begin
     DefaultCharLengthPChar:=length(Str);
   end;
 
 
-function DefaultCodePointLength(const Str: PChar; MaxLookAead: PtrInt): Ptrint;
+function DefaultCodePointLength(const Str: PAnsiChar; MaxLookAead: PtrInt): Ptrint;
   begin
     if str[0]<>#0 then
       DefaultCodePointLength:=1
@@ -294,7 +294,7 @@ begin
   result:='';
   Size:=Length(S2);
   if Size>0 then
-    widestringmanager.Ansi2UnicodeMoveProc(PChar(@S2[1]),DefaultSystemCodePage,result,Size);
+    widestringmanager.Ansi2UnicodeMoveProc(PAnsiChar(@S2[1]),DefaultSystemCodePage,result,Size);
 end;
 {$endif FPC_HAS_SHORTSTR_TO_UNICODESTR}
 
@@ -340,7 +340,7 @@ begin
   if Size>0 then
   begin
     cp:=TranslatePlaceholderCP(StringCodePage(S2));
-    widestringmanager.Ansi2UnicodeMoveProc(PChar(S2),cp,result,Size);
+    widestringmanager.Ansi2UnicodeMoveProc(PAnsiChar(S2),cp,result,Size);
   end;
 end;
 {$endif FPC_HAS_ANSISTR_TO_UNICODESTR}
@@ -565,7 +565,7 @@ end;
 
 {$ifndef FPC_HAS_CHAR_TO_UCHAR}
 {$define FPC_HAS_CHAR_TO_UCHAR}
-Function fpc_Char_To_UChar(const c : Char): UnicodeChar; compilerproc;
+Function fpc_Char_To_UChar(const c : AnsiChar): UnicodeChar; compilerproc;
 var
   w: unicodestring;
 begin
@@ -577,9 +577,9 @@ end;
 
 {$ifndef FPC_HAS_CHAR_TO_UNICODESTR}
 {$define FPC_HAS_CHAR_TO_UNICODESTR}
-Function fpc_Char_To_UnicodeStr(const c : Char): UnicodeString; compilerproc;
+Function fpc_Char_To_UnicodeStr(const c : AnsiChar): UnicodeString; compilerproc;
 {
-  Converts a Char to a UnicodeString;
+  Converts a AnsiChar to a UnicodeString;
 }
 begin
   widestringmanager.Ansi2UnicodeMoveProc(@c,DefaultSystemCodePage,result,1);
@@ -589,9 +589,9 @@ end;
 
 {$ifndef FPC_HAS_UCHAR_TO_CHAR}
 {$define FPC_HAS_UCHAR_TO_CHAR}
-Function fpc_UChar_To_Char(const c : UnicodeChar): Char; compilerproc;
+Function fpc_UChar_To_Char(const c : UnicodeChar): AnsiChar; compilerproc;
 {
-  Converts a UnicodeChar to a Char;
+  Converts a UnicodeChar to a AnsiChar;
 }
 var
   s: ansistring;
@@ -655,7 +655,7 @@ end;
 
 {$ifndef FPC_HAS_PCHAR_TO_UNICODESTR}
 {$define FPC_HAS_PCHAR_TO_UNICODESTR}
-Function fpc_PChar_To_UnicodeStr(const p : pchar): UnicodeString; compilerproc;
+Function fpc_PChar_To_UnicodeStr(const p : PAnsiChar): UnicodeString; compilerproc;
 Var
   L : SizeInt;
 begin
@@ -672,7 +672,7 @@ end;
 
 {$ifndef FPC_HAS_CHARARRAY_TO_UNICODESTR}
 {$define FPC_HAS_CHARARRAY_TO_UNICODESTR}
-Function fpc_CharArray_To_UnicodeStr(const arr: array of char; zerobased: boolean = true): UnicodeString; compilerproc;
+Function fpc_CharArray_To_UnicodeStr(const arr: array of ansichar; zerobased: boolean = true): UnicodeString; compilerproc;
 var
   i  : SizeInt;
 begin
@@ -689,7 +689,7 @@ begin
     end
   else
     i:=high(arr)+1;
-  widestringmanager.Ansi2UnicodeMoveProc(pchar(@arr),DefaultSystemCodePage,fpc_CharArray_To_UnicodeStr,i);
+  widestringmanager.Ansi2UnicodeMoveProc(pansichar(@arr),DefaultSystemCodePage,fpc_CharArray_To_UnicodeStr,i);
 end;
 {$endif FPC_HAS_CHARARRAY_TO_UNICODESTR}
 
@@ -799,7 +799,7 @@ end;
 
 {$ifndef FPC_HAS_UNICODESTR_TO_CHARARRAY}
 {$define FPC_HAS_UNICODESTR_TO_CHARARRAY}
-procedure fpc_unicodestr_to_chararray(out res: array of char; const src: UnicodeString); compilerproc;
+procedure fpc_unicodestr_to_chararray(out res: array of AnsiChar; const src: UnicodeString); compilerproc;
 var
   len: SizeInt;
   temp: ansistring;
@@ -830,7 +830,7 @@ begin
   len := length(src);
   { make sure we don't dereference src if it can be nil (JM) }
   if len > 0 then
-    widestringmanager.ansi2widemoveproc(pchar(@src[1]),TranslatePlaceholderCP(StringCodePage(src)),temp,len);
+    widestringmanager.ansi2widemoveproc(pansichar(@src[1]),TranslatePlaceholderCP(StringCodePage(src)),temp,len);
   len := length(temp);
   if len > length(res) then
     len := length(res);
@@ -851,9 +851,9 @@ var
   temp : widestring;
 begin
   len := length(src);
-  { make sure we don't access char 1 if length is 0 (JM) }
+  { make sure we don't access AnsiChar 1 if length is 0 (JM) }
   if len > 0 then
-    widestringmanager.ansi2widemoveproc(pchar(@src[1]),DefaultSystemCodePage,temp,len);
+    widestringmanager.ansi2widemoveproc(pansichar(@src[1]),DefaultSystemCodePage,temp,len);
   len := length(temp);
   if len > length(res) then
     len := length(res);
@@ -1045,7 +1045,7 @@ function StringToWideChar(const Src : RawByteString;Dest : PWideChar;DestSize :
     temp: widestring;
     Len: SizeInt;
   begin
-     widestringmanager.Ansi2WideMoveProc(PChar(Src),StringCodePage(Src),temp,Length(Src));
+     widestringmanager.Ansi2WideMoveProc(PAnsiChar(Src),StringCodePage(Src),temp,Length(Src));
      Len:=Length(temp);
      if DestSize<=Len then
        Len:=Destsize-1;
@@ -1259,11 +1259,11 @@ end;
 
 {$ifndef FPC_HAS_POS_CHAR_UNICODESTR}
 {$define FPC_HAS_POS_CHAR_UNICODESTR}
-{ Faster version for a char alone. Must be implemented because   }
-{ pos(c: char; const s: shortstring) also exists, so otherwise   }
-{ using pos(char,pchar) will always call the shortstring version }
+{ Faster version for a AnsiChar alone. Must be implemented because   }
+{ pos(c: AnsiChar; const s: shortstring) also exists, so otherwise   }
+{ using pos(AnsiChar,pansichar) will always call the shortstring version }
 { (exact match for first argument), also with $h+ (JM)           }
-Function Pos (c : Char; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
+Function Pos (c : AnsiChar; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
 var
   ns,idx: SizeInt;
 begin
@@ -1378,7 +1378,7 @@ end;
 
 {$ifndef FPC_HAS_SETSTRING_UNICODESTR_PCHAR}
 {$define FPC_HAS_SETSTRING_UNICODESTR_PCHAR}
-Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_unicodestr_pansichar{$else}SetString{$endif}(Out S : UnicodeString; Buf : PChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
+Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_unicodestr_pansichar{$else}SetString{$endif}(Out S : UnicodeString; Buf : PAnsiChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
 begin
   If (Buf<>Nil) and (Len>0) then
     widestringmanager.Ansi2UnicodeMoveProc(Buf,DefaultSystemCodePage,S,Len)
@@ -1681,7 +1681,7 @@ end;
 {$endif CPU16 or CPU8}
 
 
-function UnicodeToUtf8(Dest: PChar; Source: PUnicodeChar; MaxBytes: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+function UnicodeToUtf8(Dest: PAnsiChar; Source: PUnicodeChar; MaxBytes: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     if assigned(Source) then
       Result:=UnicodeToUtf8(Dest,MaxBytes,Source,Length(Source))
@@ -1690,7 +1690,7 @@ function UnicodeToUtf8(Dest: PChar; Source: PUnicodeChar; MaxBytes: SizeInt): Si
   end;
 
 
-function UnicodeToUtf8(Dest: PChar; MaxDestBytes: SizeUInt; Source: PUnicodeChar; SourceChars: SizeUInt): SizeUInt;
+function UnicodeToUtf8(Dest: PAnsiChar; MaxDestBytes: SizeUInt; Source: PUnicodeChar; SourceChars: SizeUInt): SizeUInt;
 {$ifdef EXCLUDE_COMPLEX_PROCS}
 begin
   runerror(217);
@@ -1713,24 +1713,24 @@ end;
             case lw of
               0..$7f:
                 begin
-                  Dest[j]:=char(lw);
+                  Dest[j]:=AnsiChar(lw);
                   inc(j);
                 end;
               $80..$7ff:
                 begin
                   if j+1>=MaxDestBytes then
                     break;
-                  Dest[j]:=char($c0 or (lw shr 6));
-                  Dest[j+1]:=char($80 or (lw and $3f));
+                  Dest[j]:=AnsiChar($c0 or (lw shr 6));
+                  Dest[j+1]:=AnsiChar($80 or (lw and $3f));
                   inc(j,2);
                 end;
               $800..$d7ff,$e000..$ffff:
                 begin
                   if j+2>=MaxDestBytes then
                     break;
-                  Dest[j]:=char($e0 or (lw shr 12));
-                  Dest[j+1]:=char($80 or ((lw shr 6) and $3f));
-                  Dest[j+2]:=char($80 or (lw and $3f));
+                  Dest[j]:=AnsiChar($e0 or (lw shr 12));
+                  Dest[j+1]:=AnsiChar($80 or ((lw shr 6) and $3f));
+                  Dest[j+2]:=AnsiChar($80 or (lw and $3f));
                   inc(j,3);
                 end;
               $d800..$dbff:
@@ -1744,10 +1744,10 @@ end;
                     begin
                       { $d7c0 is ($d800 - ($10000 shr 10)) }
                       lw:=(longword(lw-$d7c0) shl 10) + (ord(source[i+1]) xor $dc00);
-                      Dest[j]:=char($f0 or (lw shr 18));
-                      Dest[j+1]:=char($80 or ((lw shr 12) and $3f));
-                      Dest[j+2]:=char($80 or ((lw shr 6) and $3f));
-                      Dest[j+3]:=char($80 or (lw and $3f));
+                      Dest[j]:=AnsiChar($f0 or (lw shr 18));
+                      Dest[j+1]:=AnsiChar($80 or ((lw shr 12) and $3f));
+                      Dest[j+2]:=AnsiChar($80 or ((lw shr 6) and $3f));
+                      Dest[j+3]:=AnsiChar($80 or (lw and $3f));
                       inc(j,4);
                       inc(i);
                     end;
@@ -1791,7 +1791,7 @@ end;
 {$endif EXCLUDE_COMPLEX_PROCS}
 
 
-function Utf8ToUnicode(Dest: PUnicodeChar; Source: PChar; MaxChars: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Utf8ToUnicode(Dest: PUnicodeChar; Source: PAnsiChar; MaxChars: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     if assigned(Source) then
       Result:=Utf8ToUnicode(Dest,MaxChars,Source,length(Source),True)
@@ -1800,13 +1800,13 @@ function Utf8ToUnicode(Dest: PUnicodeChar; Source: PChar; MaxChars: SizeInt): Si
   end;
 
 
-function UTF8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PChar; SourceBytes: SizeUInt): SizeUInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+function UTF8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PAnsiChar; SourceBytes: SizeUInt): SizeUInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 begin
   Result:=Utf8ToUnicode(Dest,MaxDestChars,Source,SourceBytes,True);
 end;
 
-function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PChar; SourceBytes: SizeUInt; IgnoreInvalid : Boolean): SizeUInt;
+function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PAnsiChar; SourceBytes: SizeUInt; IgnoreInvalid : Boolean): SizeUInt;
 
 {$ifdef EXCLUDE_COMPLEX_PROCS}
 begin
@@ -1862,7 +1862,7 @@ end;
                 if SizeUInt(InputUTF8+CharLen-1)>SourceBytes then
                   begin
                     //Insuficient chars in string to decode
-                    //UTF-8 array. Fallback to single char.
+                    //UTF-8 array. Fallback to single AnsiChar.
                     CharLen:= 1;
                   end;
                 for LookAhead := 1 to CharLen-1 do
@@ -1976,7 +1976,7 @@ end;
                 if SizeUInt(InputUTF8+CharLen-1)>SourceBytes then
                   begin
                     //Insuficient chars in string to decode
-                    //UTF-8 array. Fallback to single char.
+                    //UTF-8 array. Fallback to single AnsiChar.
                     CharLen:= 1;
                   end;
                 for LookAhead := 1 to CharLen-1 do
@@ -2067,7 +2067,7 @@ function UTF8Encode(const s : UnicodeString) : RawByteString;
     if s='' then
       exit;
     SetLength(hs,length(s)*3);
-    i:=UnicodeToUtf8(pchar(hs),length(hs)+1,PUnicodeChar(s),length(s));
+    i:=UnicodeToUtf8(pansichar(hs),length(hs)+1,PUnicodeChar(s),length(s));
     if i>0 then
       begin
         SetLength(hs,i-1);
@@ -2088,7 +2088,7 @@ function UTF8Decode(const s : RawByteString): UnicodeString;
     if s='' then
       exit;
     SetLength(hs,length(s));
-    i:=Utf8ToUnicode(PUnicodeChar(hs),length(hs)+1,pchar(s),length(s));
+    i:=Utf8ToUnicode(PUnicodeChar(hs),length(hs)+1,pansichar(s),length(s));
     if i>0 then
       begin
         SetLength(hs,i-1);
@@ -2402,7 +2402,7 @@ begin
   Count := Length(S);
   SetLength(rs, Count);
   if Count > 0 then
-    fpc_pchar_ansistr_intern_charmove(pchar(@S),Low(S),rs,0,Count);
+    fpc_pchar_ansistr_intern_charmove(pansichar(@S),Low(S),rs,0,Count);
   Result := UTF8ToString(rs);
 end;
 {$endif not CPUJVM}

+ 3 - 3
rtl/inc/uuchar.pp

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal Run time library.
     Copyright (c) 2011 by the Free Pascal development team
 
-    This unit redefines the Char type from ansichar into widechar
+    This unit redefines the AnsiChar type from ansichar into widechar
 
     See the file COPYING.FPC, included in this distribution,
     For details about the copyright.
@@ -18,8 +18,8 @@ unit uuchar;
 interface
 
   type
-    char = widechar;
-    pchar = pwidechar;
+    AnsiChar = widechar;
+    PAnsiChar = pwidechar;
 
 
 {$ifdef FPC_HAS_FEATURE_COMMANDARGS}

+ 6 - 6
rtl/inc/variant.inc

@@ -238,7 +238,7 @@ end;
 
 { Chars }
 
-operator :=(const source : char) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : AnsiChar) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
   VariantManager.VarFromPStr(Dest,Source);
 end;
@@ -443,7 +443,7 @@ end;
 
 { Chars }
 
-operator :=(const source : variant) dest : char;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : variant) dest : AnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
 Var
   S : String;
 begin
@@ -795,7 +795,7 @@ operator :=(const source : olevariant) dest : longbool;{$ifdef SYSTEMINLINE}inli
 
 
 { Chars }
-operator :=(const source : olevariant) dest : char;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : olevariant) dest : AnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
   var
     S : String;
   begin
@@ -983,7 +983,7 @@ operator :=(const source : longbool) dest : olevariant;{$ifdef SYSTEMINLINE}inli
 
 
 { Chars }
-operator :=(const source : char) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : AnsiChar) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     variantmanager.olevarfrompstr(dest,source);
   end;
@@ -1112,7 +1112,7 @@ begin
 end;
 
 
-Function Pos (c : Char; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (c : AnsiChar; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     Result:=Pos(c,ShortString(v));
   end;
@@ -1144,7 +1144,7 @@ Function Pos (const w : UnicodeString; Const v : Variant) : SizeInt;{$ifdef SYST
 {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
 
 
-Function Pos (const v : Variant; Const c : Char) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const v : Variant; Const c : AnsiChar) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     Result:=Pos(ShortString(v),c);
   end;

+ 6 - 6
rtl/inc/varianth.inc

@@ -252,7 +252,7 @@ operator :=(const source : wordbool) dest : variant;{$ifdef SYSTEMINLINE}inline;
 operator :=(const source : longbool) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Chars }
-operator :=(const source : char) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : AnsiChar) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : widechar) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Strings }
@@ -311,7 +311,7 @@ operator :=(const source : variant) dest : wordbool;{$ifdef SYSTEMINLINE}inline;
 operator :=(const source : variant) dest : longbool;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Chars }
-operator :=(const source : variant) dest : char;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : variant) dest : AnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : variant) dest : widechar;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Strings }
@@ -400,7 +400,7 @@ operator :=(const source : olevariant) dest : wordbool;{$ifdef SYSTEMINLINE}inli
 operator :=(const source : olevariant) dest : longbool;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Chars }
-operator :=(const source : olevariant) dest : char;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : olevariant) dest : AnsiChar;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : olevariant) dest : widechar;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Strings }
@@ -455,7 +455,7 @@ operator :=(const source : wordbool) dest : olevariant;{$ifdef SYSTEMINLINE}inli
 operator :=(const source : longbool) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Chars }
-operator :=(const source : char) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
+operator :=(const source : AnsiChar) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
 operator :=(const source : widechar) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { Strings }
@@ -491,14 +491,14 @@ operator :=(const source : tdatetime) dest : olevariant;{$ifdef SYSTEMINLINE}inl
 operator :=(const source : terror) dest : olevariant;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 { silly, but how else should the compiler know what to do with pos(<string type>,<variant>)? (FK) }
-Function Pos (c : Char; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (c : AnsiChar; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (s : ShortString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (const a : AnsiString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (const w : WideString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
 Function Pos (const w : UnicodeString; Const v : Variant) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
-Function Pos (const v : Variant; Const c : Char) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function Pos (const v : Variant; Const c : AnsiChar) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (const v : Variant; Const s : ShortString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (const v : Variant; Const a : AnsiString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (const v : Variant; Const w : WideString) : SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}

+ 3 - 3
rtl/inc/wstringh.inc

@@ -17,7 +17,7 @@
 
 Procedure UniqueString (Var S : WideString);{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Pos (Const Substr : WideString; Const Source : WideString; Offset : SizeInt = 1) : SizeInt;
-Function Pos (c : Char; Const s : WideString; Offset : SizeInt = 1) : SizeInt;
+Function Pos (c : AnsiChar; Const s : WideString; Offset : SizeInt = 1) : SizeInt;
 Function Pos (c : WideChar; Const s : WideString; Offset : SizeInt = 1) : SizeInt;
 Function Pos (c : WideChar; Const s : RawByteString; Offset : SizeInt = 1) : SizeInt;
 Function Pos (const c : RawByteString; Const s : WideString; Offset : SizeInt = 1) : SizeInt;
@@ -31,9 +31,9 @@ Procedure Insert (Const Source : WideString; Var S : WideString; Index : SizeInt
 Procedure Delete (Var S : WideString; Index,Size: SizeInt);
 {$endif VER3_0}
 Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_widestr_pwidechar{$else}SetString{$endif}(Out S : WideString; Buf : PWideChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
-Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_widestr_pansichar{$else}SetString{$endif}(Out S : WideString; Buf : PChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
+Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_widestr_pansichar{$else}SetString{$endif}(Out S : WideString; Buf : PAnsiChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
 
-procedure DefaultAnsi2WideMove(source:pchar;cp : TSystemCodePage;var dest:widestring;len:SizeInt);
+procedure DefaultAnsi2WideMove(source:PAnsiChar;cp : TSystemCodePage;var dest:widestring;len:SizeInt);
 
 type
   TWideStringManager = TUnicodeStringManager;

+ 16 - 16
rtl/inc/wstrings.inc

@@ -43,13 +43,13 @@ Const
   WideFirstOff = SizeOf(TWideRec)-sizeof(WideChar);
 
 {
-  Default WideChar <-> Char conversion is to only convert the
+  Default WideChar <-> AnsiChar conversion is to only convert the
   lower 127 chars, all others are translated to spaces.
 
   These routines can be overwritten for the Current Locale
 }
 
-procedure DefaultAnsi2WideMove(source:pchar;cp : TSystemCodePage;var dest:widestring;len:SizeInt);
+procedure DefaultAnsi2WideMove(source:PAnsiChar;cp : TSystemCodePage;var dest:widestring;len:SizeInt);
 var
   i : SizeInt;
 begin
@@ -172,7 +172,7 @@ begin
   result:='';
   Size:=Length(S2);
   if Size>0 then
-    widestringmanager.Ansi2WideMoveProc(PChar(@S2[1]),DefaultSystemCodePage,result,Size);
+    widestringmanager.Ansi2WideMoveProc(PAnsiChar(@S2[1]),DefaultSystemCodePage,result,Size);
 end;
 
 
@@ -212,7 +212,7 @@ begin
   if Size>0 then
   begin
     cp:=TranslatePlaceholderCP(StringCodePage(S2));
-    widestringmanager.Ansi2WideMoveProc(PChar(S2),cp,result,Size);
+    widestringmanager.Ansi2WideMoveProc(PAnsiChar(S2),cp,result,Size);
   end;
 end;
 
@@ -340,9 +340,9 @@ end;
 
 
 
-Function fpc_Char_To_WideStr(const c : Char): WideString; compilerproc;
+Function fpc_Char_To_WideStr(const c : AnsiChar): WideString; compilerproc;
 {
-  Converts a Char to a WideString;
+  Converts a AnsiChar to a WideString;
 }
 begin
   widestringmanager.Ansi2WideMoveProc(@c,DefaultSystemCodePage,fpc_char_To_WideStr,1);
@@ -359,7 +359,7 @@ begin
 end;
 
 
-Function fpc_PChar_To_WideStr(const p : pchar): WideString; compilerproc;
+Function fpc_PChar_To_WideStr(const p : PAnsiChar): WideString; compilerproc;
 Var
   L : SizeInt;
 begin
@@ -373,7 +373,7 @@ begin
 end;
 
 
-Function fpc_CharArray_To_WideStr(const arr: array of char; zerobased: boolean = true): WideString; compilerproc;
+Function fpc_CharArray_To_WideStr(const arr: array of AnsiChar; zerobased: boolean = true): WideString; compilerproc;
 var
   i  : SizeInt;
 begin
@@ -390,11 +390,11 @@ begin
     end
   else
     i := high(arr)+1;
-  widestringmanager.Ansi2WideMoveProc(pchar(@arr),DefaultSystemCodePage,fpc_CharArray_To_WideStr,i);
+  widestringmanager.Ansi2WideMoveProc(pansichar(@arr),DefaultSystemCodePage,fpc_CharArray_To_WideStr,i);
 end;
 
 
-procedure fpc_widestr_to_chararray(out res: array of char; const src: WideString); compilerproc;
+procedure fpc_widestr_to_chararray(out res: array of AnsiChar; const src: WideString); compilerproc;
 var
   len: SizeInt;
   temp: ansistring;
@@ -665,11 +665,11 @@ Function Pos (const c : WideString; Const s : RawByteString;Offset : SizeInt = 1
     result:=Pos(c,WideString(s),Offset);
   end;
 
-{ Faster version for a char alone. Must be implemented because   }
-{ pos(c: char; const s: shortstring) also exists, so otherwise   }
-{ using pos(char,pchar) will always call the shortstring version }
+{ Faster version for a AnsiChar alone. Must be implemented because   }
+{ pos(c: ansichar; const s: shortstring) also exists, so otherwise   }
+{ using pos(AnsiChar,pansichar) will always call the shortstring version }
 { (exact match for first argument), also with $h+ (JM)           }
-Function Pos (c : Char; Const s : WideString; Offset : SizeInt = 1) : SizeInt;
+Function Pos (c : AnsiChar; Const s : WideString; Offset : SizeInt = 1) : SizeInt;
 var
   i: SizeInt;
   wc : widechar;
@@ -751,7 +751,7 @@ begin
 end;
 
 
-Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_widestr_pansichar{$else}SetString{$endif}(Out S : WideString; Buf : PChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
+Procedure {$ifdef FPC_HAS_CPSTRING}fpc_setstring_widestr_pansichar{$else}SetString{$endif}(Out S : WideString; Buf : PAnsiChar; Len : SizeInt); {$ifdef FPC_HAS_CPSTRING} compilerproc; {$endif FPC_HAS_CPSTRING}
 begin
   If (Buf<>Nil) and (Len>0) then
     widestringmanager.Ansi2WideMoveProc(Buf,DefaultSystemCodePage,S,Len)
@@ -951,7 +951,7 @@ function UTF8Encode(const s : WideString) : RawByteString;
     if s='' then
       exit;
     SetLength(hs,length(s)*3);
-    i:=UnicodeToUtf8(pchar(hs),length(hs)+1,PWideChar(s),length(s));
+    i:=UnicodeToUtf8(pansichar(hs),length(hs)+1,PWideChar(s),length(s));
     if i>0 then
       begin
         SetLength(hs,i-1);