|
@@ -407,7 +407,7 @@ begin
|
|
Size:=Length(S);
|
|
Size:=Length(S);
|
|
if Size>0 then
|
|
if Size>0 then
|
|
begin
|
|
begin
|
|
- if (cp=0) then
|
|
|
|
|
|
+ if (cp=0) or (cp=$ffff) then
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
if (StringCodePage(S)=cp) then
|
|
if (StringCodePage(S)=cp) then
|
|
begin
|
|
begin
|
|
@@ -487,13 +487,13 @@ Var
|
|
{$endif FPC_HAS_CPSTRING}
|
|
{$endif FPC_HAS_CPSTRING}
|
|
begin
|
|
begin
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
- if (cp=0) then
|
|
|
|
|
|
+ if (cp=0) or (cp=$ffff) then
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
{$else FPC_HAS_CPSTRING}
|
|
{$else FPC_HAS_CPSTRING}
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
{$endif FPC_HAS_CPSTRING}
|
|
{$endif FPC_HAS_CPSTRING}
|
|
Size:=Length(S2);
|
|
Size:=Length(S2);
|
|
- Setlength (fpc_ShortStr_To_AnsiStr,Size);
|
|
|
|
|
|
+ Setlength(fpc_ShortStr_To_AnsiStr,Size);
|
|
if Size>0 then
|
|
if Size>0 then
|
|
begin
|
|
begin
|
|
Move(S2[1],Pointer(fpc_ShortStr_To_AnsiStr)^,Size);
|
|
Move(S2[1],Pointer(fpc_ShortStr_To_AnsiStr)^,Size);
|
|
@@ -511,7 +511,7 @@ var
|
|
{$endif FPC_HAS_CPSTRING}
|
|
{$endif FPC_HAS_CPSTRING}
|
|
begin
|
|
begin
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
- if (cp=0) then
|
|
|
|
|
|
+ if (cp=0) or (cp=$ffff) then
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
{$else FPC_HAS_CPSTRING}
|
|
{$else FPC_HAS_CPSTRING}
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
@@ -539,7 +539,7 @@ begin
|
|
if L > 0 then
|
|
if L > 0 then
|
|
begin
|
|
begin
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
- if (cp=0) then
|
|
|
|
|
|
+ if (cp=0) or (cp=$ffff) then
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
{$else FPC_HAS_CPSTRING}
|
|
{$else FPC_HAS_CPSTRING}
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
@@ -574,7 +574,7 @@ begin
|
|
if i > 0 then
|
|
if i > 0 then
|
|
begin
|
|
begin
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
- if (cp=0) then
|
|
|
|
|
|
+ if (cp=0) or (cp=$ffff) then
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
{$else FPC_HAS_CPSTRING}
|
|
{$else FPC_HAS_CPSTRING}
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
@@ -772,7 +772,7 @@ begin
|
|
GetMem(Pointer(S),AnsiRecLen+L);
|
|
GetMem(Pointer(S),AnsiRecLen+L);
|
|
PAnsiRec(S)^.Ref:=1;
|
|
PAnsiRec(S)^.Ref:=1;
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
{$ifdef FPC_HAS_CPSTRING}
|
|
- if (cp=0) then
|
|
|
|
|
|
+ if (cp=0) or (cp=$ffff) then
|
|
cp:=DefaultSystemCodePage;
|
|
cp:=DefaultSystemCodePage;
|
|
PAnsiRec(S)^.CodePage:=cp;
|
|
PAnsiRec(S)^.CodePage:=cp;
|
|
{$else}
|
|
{$else}
|
|
@@ -1244,14 +1244,14 @@ end;
|
|
|
|
|
|
{$endif CPU64}
|
|
{$endif CPU64}
|
|
|
|
|
|
-Procedure Delete (Var S : RawByteString; Index,Size: SizeInt);
|
|
|
|
|
|
+Procedure Delete(Var S : RawByteString; Index,Size: SizeInt);
|
|
Var
|
|
Var
|
|
LS : SizeInt;
|
|
LS : SizeInt;
|
|
begin
|
|
begin
|
|
ls:=Length(S);
|
|
ls:=Length(S);
|
|
If (Index>LS) or (Index<=0) or (Size<=0) then
|
|
If (Index>LS) or (Index<=0) or (Size<=0) then
|
|
exit;
|
|
exit;
|
|
- UniqueString (S);
|
|
|
|
|
|
+ UniqueString(S);
|
|
If (Size>LS-Index) then // Size+Index gives overflow ??
|
|
If (Size>LS-Index) then // Size+Index gives overflow ??
|
|
Size:=LS-Index+1;
|
|
Size:=LS-Index+1;
|
|
If (Size<=LS-Index) then
|
|
If (Size<=LS-Index) then
|
|
@@ -1263,10 +1263,11 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-Procedure Insert (Const Source : RawByteString; Var S : RawByteString; Index : SizeInt);
|
|
|
|
|
|
+Procedure Insert(Const Source : RawByteString; Var S : RawByteString; Index : SizeInt);
|
|
var
|
|
var
|
|
Temp : RawByteString;
|
|
Temp : RawByteString;
|
|
LS : SizeInt;
|
|
LS : SizeInt;
|
|
|
|
+ cp : TSystemCodePage;
|
|
begin
|
|
begin
|
|
If Length(Source)=0 then
|
|
If Length(Source)=0 then
|
|
exit;
|
|
exit;
|
|
@@ -1276,11 +1277,14 @@ begin
|
|
if index > LS then
|
|
if index > LS then
|
|
index := LS+1;
|
|
index := LS+1;
|
|
Dec(Index);
|
|
Dec(Index);
|
|
- Pointer(Temp) := NewAnsiString(Length(Source)+LS);
|
|
|
|
SetLength(Temp,Length(Source)+LS);
|
|
SetLength(Temp,Length(Source)+LS);
|
|
|
|
+ cp:=StringCodePage(S);
|
|
|
|
+ if (cp=0) or (cp=$ffff) then
|
|
|
|
+ cp:=DefaultSystemCodePage;
|
|
|
|
+ SetCodePage(Temp,cp,false);
|
|
If Index>0 then
|
|
If Index>0 then
|
|
- move (Pointer(S)^,Pointer(Temp)^,Index);
|
|
|
|
- Move (Pointer(Source)^,PByte(Temp)[Index],Length(Source));
|
|
|
|
|
|
+ Move(Pointer(S)^,Pointer(Temp)^,Index);
|
|
|
|
+ Move(Pointer(Source)^,PByte(Temp)[Index],Length(Source));
|
|
If (LS-Index)>0 then
|
|
If (LS-Index)>0 then
|
|
Move(PByte(Pointer(S))[Index],PByte(temp)[Length(Source)+index],LS-Index);
|
|
Move(PByte(Pointer(S))[Index],PByte(temp)[Length(Source)+index],LS-Index);
|
|
S:=Temp;
|
|
S:=Temp;
|