Browse Source

AnsiString to String

Pascal Coin 6 years ago
parent
commit
43088cd352
2 changed files with 10 additions and 10 deletions
  1. 5 5
      src/libraries/pascalcoin/UJSONFunctions.pas
  2. 5 5
      src/libraries/sphere10/UCommon.pas

+ 5 - 5
src/libraries/pascalcoin/UJSONFunctions.pas

@@ -503,7 +503,7 @@ begin
   {$ELSE}
   if JSONValue is TJSONNumber then begin
     d := TJSONNumber(JSONValue).AsDouble;
-    if Pos('.',JSONValue.ToString)>0 then i64 := 0
+    if JSONValue.ToString.IndexOf('.')>=0 then i64 := 0
     else i64 := TJSONNumber(JSONValue).AsInt;
     ds := {$IFDEF DELPHIXE}FormatSettings.{$ENDIF}DecimalSeparator;
     ts := {$IFDEF DELPHIXE}FormatSettings.{$ENDIF}ThousandSeparator;
@@ -717,11 +717,11 @@ end;
 procedure TPCJSONObject.CheckValidName(Name: String);
 Var i : Integer;
 begin
-  for i := 1 to Length(Name) do begin
-    if i=1 then begin
-      if Not (Name[i] in ['a'..'z','A'..'Z','0'..'9','_','.']) then raise Exception.Create(Format('Invalid char %s at pos %d/%d',[Name[i],i,length(Name)]));
+  for i := 0 to Length(Name)-1 do begin
+    if i=0 then begin
+      if Not (Name.Chars[i] in ['a'..'z','A'..'Z','0'..'9','_','.']) then raise Exception.Create(Format('Invalid char %s at pos %d/%d',[Name.Chars[i],i+1,length(Name)]));
     end else begin
-      if Not (Name[i] in ['a'..'z','A'..'Z','0'..'9','_','-','.']) then raise Exception.Create(Format('Invalid char %s at pos %d/%d',[Name[i],i,length(Name)]));
+      if Not (Name.Chars[i] in ['a'..'z','A'..'Z','0'..'9','_','-','.']) then raise Exception.Create(Format('Invalid char %s at pos %d/%d',[Name.Chars[i],i+1,length(Name)]));
     end;
   end;
 end;

+ 5 - 5
src/libraries/sphere10/UCommon.pas

@@ -42,10 +42,10 @@ const
 
 { GLOBAL HELPER FUNCTIONS }
 
-function String2Hex(const Buffer: AnsiString): AnsiString;
+{function String2Hex(const Buffer: AnsiString): AnsiString;
 function Hex2Bytes(const AHexString: AnsiString): TBytes; overload;
 function TryHex2Bytes(const AHexString: AnsiString; out ABytes : TBytes): boolean; overload;
-function Bytes2Hex(const ABytes: TBytes; AUsePrefix : boolean = false) : AnsiString;
+function Bytes2Hex(const ABytes: TBytes; AUsePrefix : boolean = false) : AnsiString;}
 function BinStrComp(const Str1, Str2 : String): Integer; // Binary-safe StrComp replacement. StrComp will return 0 for when str1 and str2 both start with NUL character.
 function BytesCompare(const ABytes1, ABytes2: TBytes): integer;
 function BytesEqual(const ABytes1, ABytes2 : TBytes) : boolean; inline;
@@ -401,7 +401,7 @@ resourcestring
 
 implementation
 
-uses dateutils, {$IFDEF FPC}StrUtils{$ELSE}System.AnsiStrings{$ENDIF};
+uses dateutils {$IFDEF FPC},StrUtils{$ELSE}{,System.AnsiStrings}{$ENDIF};
 
 const
   IntlDateTimeFormat : TFormatSettings = (
@@ -433,7 +433,7 @@ var
 
 { Global helper functions }
 
-function String2Hex(const Buffer: AnsiString): AnsiString;
+{function String2Hex(const Buffer: AnsiString): AnsiString;
 var
   n: Integer;
 begin
@@ -509,7 +509,7 @@ begin
     Result[(i*2)+ LStart + 1] := s[2];
     Inc(i);
   end;
-end;
+end;      }
 
 function BinStrComp(const Str1, Str2: String): integer;
 var Str1Len, Str2Len, i : Integer;