Quellcode durchsuchen

+ several pwidechar/unicode string functions added

git-svn-id: trunk@24212 -
florian vor 12 Jahren
Ursprung
Commit
c25f56fa64

+ 4 - 4
rtl/objpas/sysutils/syspchh.inc

@@ -24,18 +24,18 @@ function strcat(dest,source : pchar) : pchar;
 function strcomp(str1,str2 : pchar) : SizeInt;
 function strlcomp(str1,str2 : pchar;l : SizeInt) : SizeInt;
 function stricomp(str1,str2 : pchar) : SizeInt;
-function strmove(dest,source : pchar;l : SizeInt) : pchar;
+function strmove(dest,source : pchar;l : SizeInt) : pchar; overload;
 function strlcat(dest,source : pchar;l : SizeInt) : pchar;
-function strscan(p : pchar;c : char) : pchar;
+function strscan(p : pchar;c : char) : pchar; overload;
 function strrscan(p : pchar;c : char) : pchar;
 function strlower(p : pchar) : pchar;
 function strupper(p : pchar) : pchar;
 function strlicomp(str1,str2 : pchar;l : SizeInt) : SizeInt;
 function strpos(str1,str2 : pchar) : pchar;
-function strnew(p : pchar) : pchar;
+function strnew(p : pchar) : pchar; overload;
 
 { Different from strings unit - ansistrings or different behaviour }
-function StrPas(Str: PChar): string;
+function StrPas(Str: PChar): string;overload;
 function StrPCopy(Dest: PChar; Source: string): PChar;overload;
 function StrPLCopy(Dest: PChar; Source: string; MaxLen: SizeUInt): PChar;overload;
 function StrAlloc(Size: cardinal): PChar;

+ 55 - 2
rtl/objpas/sysutils/sysuni.inc

@@ -144,6 +144,13 @@ begin
 end;
 
 
+function StrMove(dest,source : PWideChar;l : SizeInt) : PWideChar; overload;
+ begin
+   move(source^,dest^,l*2);
+   Result:=dest;
+ end;
+
+
 function StrPLCopy(Dest: PWideChar; const Source: UnicodeString; MaxLen: SizeInt): PWideChar; overload;
 var Len: SizeInt;
 begin
@@ -161,12 +168,57 @@ begin
   StrPCopy := StrPLCopy(Dest, Source, length(Source));
 end;
 
-{$IFNDEF VER2_4}
+
+function StrScan(P: PWideChar; C: WideChar): PWideChar;
+Var
+   count: SizeInt;
+Begin
+ count := 0;
+ { As in Borland Pascal, if looking for NULL return null }
+ if C = #0 then
+ begin
+   StrScan := @(P[StrLen(P)]);
+   exit;
+ end;
+ { Find first matching character of Ch in Str }
+ while P[count] <> #0 do
+ begin
+   if C = P[count] then
+    begin
+        StrScan := @(P[count]);
+        exit;
+    end;
+   Inc(count);
+ end;
+ { nothing found. }
+ StrScan := nil;
+end;
+
+
+function strnew(p : PWideChar) : PWideChar; overload;
+var
+  len : SizeInt;
+begin
+  Result:=nil;
+  if (p=nil) or (p^=#0) then
+   exit;
+  len:=strlen(p)+1;
+  Result:=PWideChar(StrAlloc(Len*2));
+  if Result<>nil then
+   strmove(Result,p,len);
+end;
+
+function StrPas(Str: PWideChar): UnicodeString;overload;
+begin
+  Result:=Str;
+end;
+
 function BytesOf(const Val: UnicodeString): TBytes;
 begin
   Result:=TEncoding.Default.GetBytes(Val);
 end;
 
+
 function BytesOf(const Val: WideChar): TBytes; overload;
 begin
   Result:=TEncoding.Default.GetBytes(Val);
@@ -176,7 +228,8 @@ function StringOf(const Bytes: TBytes): UnicodeString;
 begin
   Result:=TEncoding.Default.GetString(Bytes);
 end;
-{$ENDIF VER2_4}
+
+
 function WideBytesOf(const Value: UnicodeString): TBytes;
 var
   Len:Integer;

+ 6 - 2
rtl/objpas/sysutils/sysunih.inc

@@ -32,13 +32,17 @@ Function UnicodeFormatBuf (Var Buffer; BufLen : Cardinal; Const Fmt; fmtLen : Ca
 Procedure UnicodeFmtStr(Var Res: UnicodeString; Const Fmt : UnicodeString; Const args: Array of const);
 Procedure UnicodeFmtStr(Var Res: UnicodeString; Const Fmt : UnicodeString; Const args: Array of const; Const FormatSettings: TFormatSettings);
 
+function StrMove(dest,source : PWideChar;l : SizeInt) : PWideChar; overload;
 function StrPLCopy(Dest: PWideChar; const Source: UnicodeString; MaxLen: SizeInt): PWideChar; overload;
 function StrPCopy(Dest: PWideChar; const Source: UnicodeString): PWideChar; overload;
-{$IFNDEF VER2_4}
+function StrScan(P: PWideChar; C: WideChar): PWideChar; overload;
+function strnew(p : PWideChar) : PWideChar; overload;
+
+function StrPas(Str: PWideChar): UnicodeString;overload;
+
 function BytesOf(const Val: UnicodeString): TBytes; overload;
 function BytesOf(const Val: WideChar): TBytes; overload;
 function StringOf(const Bytes: TBytes): UnicodeString;
-{$ENDIF VER2_4}
 function WideBytesOf(const Value: UnicodeString): TBytes;
 function WideStringOf(const Value: TBytes): UnicodeString;
 function ByteLength(const S: UnicodeString): Integer;