Browse Source

* Complete the implementation of IsLeadChar

git-svn-id: trunk@41336 -
michael 6 years ago
parent
commit
3fcc1c5f0e
3 changed files with 43 additions and 0 deletions
  1. 13 0
      rtl/objpas/sysutils/sysstr.inc
  2. 2 0
      rtl/objpas/sysutils/sysstrh.inc
  3. 28 0
      rtl/win/sysutils.pp

+ 13 - 0
rtl/objpas/sysutils/sysstr.inc

@@ -76,6 +76,19 @@ begin
 Dest := Dest + S;
 Dest := Dest + S;
 end ;
 end ;
 
 
+function IsLeadChar(C: AnsiChar): Boolean; inline;
+
+begin
+  Result:=C in LeadBytes;
+end;
+
+function IsLeadChar(B: Byte): Boolean; inline;
+
+
+begin
+  Result:=Char(B) in LeadBytes;
+end;
+
 Function InternalChangeCase(Const S : AnsiString; const Chars: TSysCharSet; const Adjustment: Longint): AnsiString;
 Function InternalChangeCase(Const S : AnsiString; const Chars: TSysCharSet; const Adjustment: Longint): AnsiString;
   var
   var
     i : Integer;
     i : Integer;

+ 2 - 0
rtl/objpas/sysutils/sysstrh.inc

@@ -251,6 +251,8 @@ Function CharToByteLen(const S: string; MaxLen: SizeInt): SizeInt;
 Function ByteToCharIndex(const S: string; Index: SizeInt): SizeInt;
 Function ByteToCharIndex(const S: string; Index: SizeInt): SizeInt;
 Function StrCharLength(const Str: PChar): SizeInt;
 Function StrCharLength(const Str: PChar): SizeInt;
 function StrNextChar(const Str: PChar): PChar;
 function StrNextChar(const Str: PChar): PChar;
+function IsLeadChar(C: AnsiChar): Boolean; inline; overload;
+function IsLeadChar(B: Byte): Boolean; inline; overload;
 
 
 
 
 const
 const

+ 28 - 0
rtl/win/sysutils.pp

@@ -1038,6 +1038,34 @@ begin
   GetlocaleFormatSettings(GetThreadLocale, DefaultFormatSettings);
   GetlocaleFormatSettings(GetThreadLocale, DefaultFormatSettings);
 end;
 end;
 
 
+Procedure InitLeadBytes;
+
+var
+  I,B,C,E: Byte;
+  Info: TCPInfo;
+
+begin
+  GetCPInfo(CP_ACP,Info);
+  I:=0;
+  With Info do
+    begin
+    B:=LeadByte[i];
+    E:=LeadByte[i+1];
+    while (I<MAX_LEADBYTES) and (B<>0) and (E<>0) do
+      begin
+      for C:=B to E do
+        Include(LeadBytes,AnsiChar(C));
+      Inc(I,2);
+      if (I<MAX_LEADBYTES) then
+        begin
+        B:=LeadByte[i];
+        E:=LeadByte[i+1];
+        end;
+      end;
+    end;   
+end;
+
+
 Procedure InitInternational;
 Procedure InitInternational;
 var
 var
   { A call to GetSystemMetrics changes the value of the 8087 Control Word on
   { A call to GetSystemMetrics changes the value of the 8087 Control Word on