ソースを参照

* String/AnsiString corrections

Michael VAN CANNEYT 2 年 前
コミット
ac158bcf72
2 ファイル変更17 行追加15 行削除
  1. 8 7
      rtl/objpas/sysutils/sysencoding.inc
  2. 9 8
      rtl/objpas/sysutils/sysencodingh.inc

+ 8 - 7
rtl/objpas/sysutils/sysencoding.inc

@@ -1,3 +1,4 @@
+{%MainUnit sysutils.pp}
 {
     *********************************************************************
     Copyright (C) 2012 Paul Ishenin,
@@ -35,7 +36,7 @@ begin
   Result := FStandardEncodings[seAnsi];
 end;
 
-function TEncoding.GetAnsiBytes(const S: string): TBytes;
+function TEncoding.GetAnsiBytes(const S: ansistring): TBytes;
 begin
   if S='' then
     Result := nil
@@ -43,13 +44,13 @@ begin
     Result := GetAnsiBytes(S, 1, Length(S));
 end;
 
-function TEncoding.GetAnsiBytes(const S: string; CharIndex, CharCount: Integer
+function TEncoding.GetAnsiBytes(const S: ansistring; CharIndex, CharCount: Integer
   ): TBytes;
 begin
   Result := GetAnsiBytes(Pointer(@S[CharIndex]), CharCount);
 end;
 
-function TEncoding.GetAnsiString(const Bytes: TBytes): string;
+function TEncoding.GetAnsiString(const Bytes: TBytes): ansistring;
 begin
   if Length(Bytes)=0 then
     Result := ''
@@ -58,7 +59,7 @@ begin
 end;
 
 function TEncoding.GetAnsiString(const Bytes: TBytes; ByteIndex,
-  ByteCount: Integer): string;
+  ByteCount: Integer): ansistring;
 begin
   Result := GetAnsiString(Pointer(@Bytes[ByteIndex]), ByteCount);
   SetCodePage(RawByteString(Result), DefaultSystemCodePage, False);
@@ -572,7 +573,7 @@ begin
     Move(S[1], Result[0], Length(S));
 end;
 
-function TMBCSEncoding.GetAnsiString(Bytes: PByte; ByteCount: Integer): string;
+function TMBCSEncoding.GetAnsiString(Bytes: PByte; ByteCount: Integer): ansistring;
 begin
   SetString(Result, Pointer(Bytes), ByteCount);
   SetCodePage(RawByteString(Result), GetCodePage, False);
@@ -735,7 +736,7 @@ begin
 end;
 
 function TUnicodeEncoding.GetAnsiString(Bytes: PByte; ByteCount: Integer
-  ): string;
+  ): ansistring;
 begin
   widestringmanager.Unicode2AnsiMoveProc(PUnicodeChar(Bytes), RawByteString(Result), DefaultSystemCodePage, ByteCount div SizeOf(UnicodeChar));
 end;
@@ -819,7 +820,7 @@ begin
 end;
 
 function TBigEndianUnicodeEncoding.GetAnsiString(Bytes: PByte;
-  ByteCount: Integer): string;
+  ByteCount: Integer): ansistring;
 var
   B: TBytes;
 begin

+ 9 - 8
rtl/objpas/sysutils/sysencodingh.inc

@@ -1,3 +1,4 @@
+{%MainUnit sysutils.pp}
 {
     *********************************************************************
     Copyright (C) 2012 Paul Ishenin,
@@ -52,7 +53,7 @@ type
     function GetCharCount(Bytes: PByte; ByteCount: Integer): Integer; overload; virtual; abstract;
     function GetChars(Bytes: PByte; ByteCount: Integer; Chars: PUnicodeChar; CharCount: Integer): Integer; overload; virtual; abstract;
     function GetAnsiBytes(Chars: PAnsiChar; CharCount: Integer): TBytes; virtual; abstract;
-    function GetAnsiString(Bytes: PByte; ByteCount: Integer): string; virtual; abstract;
+    function GetAnsiString(Bytes: PByte; ByteCount: Integer): ansistring; virtual; abstract;
     function GetCodePage: Cardinal; virtual; abstract;
     function GetEncodingName: UnicodeString; virtual; abstract;
   public
@@ -87,10 +88,10 @@ type
     function GetPreamble: TBytes; virtual; abstract;
     function GetString(const Bytes: TBytes): UnicodeString; overload;
     function GetString(const Bytes: TBytes; ByteIndex, ByteCount: Integer): UnicodeString; overload;
-    function GetAnsiBytes(const S: string): TBytes; overload;
-    function GetAnsiBytes(const S: string; CharIndex, CharCount: Integer): TBytes; overload;
-    function GetAnsiString(const Bytes: TBytes): string; overload;
-    function GetAnsiString(const Bytes: TBytes; ByteIndex, ByteCount: Integer): string; overload;
+    function GetAnsiBytes(const S: Ansistring): TBytes; overload;
+    function GetAnsiBytes(const S: Ansistring; CharIndex, CharCount: Integer): TBytes; overload;
+    function GetAnsiString(const Bytes: TBytes): ansistring; overload;
+    function GetAnsiString(const Bytes: TBytes; ByteIndex, ByteCount:  Integer):ansistring; overload;
 
     property CodePage: Cardinal read GetCodePage;
     property EncodingName: UnicodeString read GetEncodingName;
@@ -119,7 +120,7 @@ type
     function GetCharCount(Bytes: PByte; ByteCount: Integer): Integer; overload; override;
     function GetChars(Bytes: PByte; ByteCount: Integer; Chars: PUnicodeChar; CharCount: Integer): Integer; overload; override;
     function GetAnsiBytes(Chars: PAnsiChar; CharCount: Integer): TBytes; override;
-    function GetAnsiString(Bytes: PByte; ByteCount: Integer): string; override;
+    function GetAnsiString(Bytes: PByte; ByteCount: Integer): ansistring; override;
     function GetCodePage: Cardinal; override;
     function GetEncodingName: UnicodeString; override;
   public
@@ -162,7 +163,7 @@ type
     function GetCharCount(Bytes: PByte; ByteCount: Integer): Integer; overload; override;
     function GetChars(Bytes: PByte; ByteCount: Integer; Chars: PUnicodeChar; CharCount: Integer): Integer; overload; override;
     function GetAnsiBytes(Chars: PAnsiChar; CharCount: Integer): TBytes; override;
-    function GetAnsiString(Bytes: PByte; ByteCount: Integer): string; override;
+    function GetAnsiString(Bytes: PByte; ByteCount: Integer): ansistring; override;
     function GetCodePage: Cardinal; override;
     function GetEncodingName: UnicodeString; override;
   public
@@ -181,7 +182,7 @@ type
     function GetBytes(Chars: PUnicodeChar; CharCount: Integer; Bytes: PByte; ByteCount: Integer): Integer; overload; override;
     function GetChars(Bytes: PByte; ByteCount: Integer; Chars: PUnicodeChar; CharCount: Integer): Integer; overload; override;
     function GetAnsiBytes(Chars: PAnsiChar; CharCount: Integer): TBytes; override;
-    function GetAnsiString(Bytes: PByte; ByteCount: Integer): string; override;
+    function GetAnsiString(Bytes: PByte; ByteCount: Integer): ansistring; override;
     function GetCodePage: Cardinal; override;
     function GetEncodingName: UnicodeString; override;
   public