mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-04 04:57:23 +01:00
+ pchar -> short/ansi/unicodestring support
git-svn-id: branches/jvmbackend@18767 -
This commit is contained in:
parent
1ff004312b
commit
27f2edea57
@ -268,20 +268,21 @@ begin
|
||||
result:=ansistring(AnsistringClass.Create(c));
|
||||
end;
|
||||
|
||||
(*
|
||||
|
||||
Function fpc_PChar_To_AnsiStr(const p : pchar): ansistring; compilerproc;
|
||||
Var
|
||||
L : SizeInt;
|
||||
var
|
||||
i, len: longint;
|
||||
arr: TAnsiCharArray;
|
||||
begin
|
||||
if (not assigned(p)) or (p[0]=#0) Then
|
||||
L := 0
|
||||
arr:=TAnsiCharArray(p);
|
||||
i:=0;
|
||||
while arr[i]<>#0 do
|
||||
inc(i);
|
||||
if i<>0 then
|
||||
result:=ansistring(AnsiStringClass.create(arr,i))
|
||||
else
|
||||
l:=IndexChar(p^,-1,#0);
|
||||
SetLength(fpc_PChar_To_AnsiStr,L);
|
||||
if L > 0 then
|
||||
Move (P[0],Pointer(fpc_PChar_To_AnsiStr)^,L)
|
||||
result:=''
|
||||
end;
|
||||
*)
|
||||
|
||||
|
||||
Function fpc_CharArray_To_AnsiStr(const arr: array of ansichar; zerobased: boolean = true): ansistring; compilerproc;
|
||||
|
||||
@ -45,13 +45,12 @@ procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring);
|
||||
function fpc_shortstr_compare(const left,right:shortstring) : longint; compilerproc;
|
||||
function fpc_shortstr_compare_equal(const left,right:shortstring) : longint; compilerproc;
|
||||
|
||||
(*
|
||||
{$ifndef FPC_STRTOSHORTSTRINGPROC}
|
||||
function fpc_pchar_to_shortstr(p:pchar):shortstring; compilerproc;
|
||||
{$else FPC_STRTOSHORTSTRINGPROC}
|
||||
procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar); compilerproc;
|
||||
{$endif FPC_STRTOSHORTSTRINGPROC}
|
||||
|
||||
(*
|
||||
function fpc_pchar_length(p:pchar):longint; compilerproc;
|
||||
function fpc_pwidechar_length(p:pwidechar):longint; compilerproc;
|
||||
*)
|
||||
@ -256,9 +255,7 @@ Function fpc_ShortStr_To_AnsiStr (Const S2 : ShortString): ansistring; compilerp
|
||||
{$ifndef nounsupported}
|
||||
Function fpc_Char_To_AnsiStr(const c : AnsiChar): AnsiString; compilerproc;
|
||||
{$endif}
|
||||
(*
|
||||
Function fpc_PChar_To_AnsiStr(const p : pchar): ansistring; compilerproc;
|
||||
*)
|
||||
{$ifndef nounsupported}
|
||||
Function fpc_CharArray_To_AnsiStr(const arr: array of AnsiChar; zerobased: boolean = true): ansistring; compilerproc;
|
||||
procedure fpc_ansistr_to_chararray(out res: array of AnsiChar; const src: ansistring)compilerproc;
|
||||
|
||||
@ -262,20 +262,22 @@ begin
|
||||
result:=u;
|
||||
end;
|
||||
|
||||
(*
|
||||
|
||||
Function fpc_PChar_To_UnicodeStr(const p : pchar): UnicodeString; compilerproc;
|
||||
Var
|
||||
L : SizeInt;
|
||||
var
|
||||
i, len: longint;
|
||||
arr: TAnsiCharArray;
|
||||
begin
|
||||
if (not assigned(p)) or (p[0]=#0) Then
|
||||
begin
|
||||
fpc_pchar_to_unicodestr := '';
|
||||
exit;
|
||||
end;
|
||||
l:=IndexChar(p^,-1,#0);
|
||||
widestringmanager.Ansi2UnicodeMoveProc(P,fpc_PChar_To_UnicodeStr,l);
|
||||
arr:=TAnsiCharArray(p);
|
||||
i:=0;
|
||||
while arr[i]<>#0 do
|
||||
inc(i);
|
||||
if i<>0 then
|
||||
result:=JLString.create(TJByteArray(arr),0,i)
|
||||
else
|
||||
result:=''
|
||||
end;
|
||||
*)
|
||||
|
||||
|
||||
Function fpc_CharArray_To_UnicodeStr(const arr: array of ansichar; zerobased: boolean = true): UnicodeString; compilerproc;
|
||||
var
|
||||
|
||||
@ -97,7 +97,22 @@ function Sptr:Pointer;
|
||||
{$define FPC_STRTOSHORTSTRINGPROC}
|
||||
{$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
|
||||
{$define FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
|
||||
|
||||
{$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
||||
procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar); compilerproc;
|
||||
var
|
||||
i, len: longint;
|
||||
arr: TAnsiCharArray;
|
||||
begin
|
||||
arr:=TAnsiCharArray(p);
|
||||
i:=0;
|
||||
while arr[i]<>#0 do
|
||||
inc(i);
|
||||
if i<>0 then
|
||||
res:=pshortstring(ShortStringClass.create(arr,min(i,high(res))))^
|
||||
else
|
||||
res:=''
|
||||
end;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
|
||||
procedure fpc_shortstr_to_shortstr(out res:shortstring; const sstr: shortstring); compilerproc;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user