Browse Source

* Fixded StrCharLength.

git-svn-id: branches/unicodertl@12139 -
yury 17 years ago
parent
commit
66b01fde58
1 changed files with 12 additions and 10 deletions
  1. 12 10
      rtl/objpas/sysutils/sysstr.inc

+ 12 - 10
rtl/objpas/sysutils/sysstr.inc

@@ -2580,17 +2580,19 @@ end;
 Function StrCharLength(const Str: PWideChar): Integer;
 Function StrCharLength(const Str: PWideChar): Integer;
 var
 var
   c: WideChar;
   c: WideChar;
-begin
-  Result:=0;
-  c:=Str^;
-  if c = #0 then exit;
-  Inc(Result);
-  Inc(Str);
-  if (c >= #$d800) and (c <= #$dbff) then begin
-    c:=Str^;
-    if (c <> #0) and (c >= #$dc00) and (c <= #$dfff) then
-      Inc(Result);
+  s: PWideChar;
+begin
+  s:=Str;
+  c:=s^;
+  if c <> #0 then begin
+    Inc(s);
+    if (c >= #$d800) and (c <= #$dbff) then begin
+      c:=s^;
+      if (c <> #0) and (c >= #$dc00) and (c <= #$dfff) then
+        Inc(s);
+    end;
   end;
   end;
+  Result:=s - Str;
 end;
 end;