Skip to content

Commit 64f8eda

Browse files
author
Andrew Zenin
committed
Added Unicode Support, yep, now it's full compatible with UTF-8
1 parent 1d10085 commit 64f8eda

18 files changed

+683
-628
lines changed

Source/DelphiFunctions.pas

+3-3
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function delphi_set_property_handler(property_reference : Pzend_property_referen
333333
element : pzend_list_element;
334334
prop : pzend_overloaded_element;
335335
p : pointer;
336-
propname : AnsiString;
336+
propname : zend_ustr;
337337
// --> hupu, 2006.06.01
338338
// pt : TTypeKind;
339339
{$IFDEF VERSION7}
@@ -409,7 +409,7 @@ procedure delphi_get_property_handler(val : pzval; property_reference : PZend_pr
409409
element : pzend_list_element;
410410
prop : pzend_overloaded_element;
411411
p : pointer;
412-
propname : AnsiString;
412+
propname : zend_ustr;
413413
// --> hupu, 2006.06.01
414414
// pt : TTypeKind;
415415
{$IFDEF VERSION7}
@@ -522,7 +522,7 @@ procedure delphi_call_function(ht : integer; return_value : pzval; this_ptr : pz
522522
element : pzend_list_element;
523523
prop : pzend_overloaded_element;
524524
p : pointer;
525-
MethodName : AnsiString;
525+
MethodName : zend_ustr;
526526
Params : pzval_array;
527527
M, D : integer;
528528
begin

Source/PHPAPI.pas

+48-12
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ interface
127127

128128

129129
function GetSymbolsTable : PHashTable;
130-
function GetTrackHash(Name : AnsiString) : PHashTable;
130+
function GetTrackHash(Name : zend_ustr) : PHashTable;
131131
function GetSAPIGlobals : Psapi_globals_struct; overload;
132132
function GetSAPIGlobals(TSRMLS_DC : pointer) : Psapi_globals_struct; overload;
133133
//procedure phperror(Error : zend_pchar);
@@ -244,7 +244,7 @@ function PG(TSRMLS_DC : pointer) : Pphp_Core_Globals;
244244

245245
procedure PHP_FUNCTION(var AFunction : zend_function_entry; AName : zend_pchar; AHandler : pointer);
246246

247-
function LoadPHP(const DllFileName: AnsiString = PHPWin) : boolean;
247+
function LoadPHP(const DllFileName: zend_ustr = PHPWin) : boolean;
248248

249249
procedure UnloadPHP;
250250

@@ -254,8 +254,8 @@ function PHPLoaded : boolean;
254254
procedure CheckPHPErrors;
255255
{$ENDIF}
256256

257-
function FloatToValue(Value: Extended): AnsiString;
258-
function ValueToFloat(Value : AnsiString) : extended;
257+
function FloatToValue(Value: Extended): zend_ustr;
258+
function ValueToFloat(Value : zend_ustr) : extended;
259259

260260

261261
var
@@ -357,7 +357,7 @@ function GetSymbolsTable : PHashTable;
357357

358358
{$ENDIF}
359359

360-
function GetTrackHash(Name : AnsiString) : PHashTable;
360+
function GetTrackHash(Name : zend_ustr) : PHashTable;
361361
var
362362
data : ^ppzval;
363363
arr : PHashTable;
@@ -431,7 +431,7 @@ function zval2variant(value : zval) : variant;
431431
IS_NULL : Result := NULL;
432432
IS_LONG : Result := Value.value.lval;
433433
IS_DOUBLE : Result := Value.value.dval;
434-
IS_STRING : Result := AnsiString(Value.Value.str.val);
434+
IS_STRING : Result := zend_ustr(Value.Value.str.val);
435435
IS_BOOL : Result := Boolean(Value.Value.lval);
436436
else
437437
Result := NULL;
@@ -495,7 +495,7 @@ procedure variant2zval(value : variant;var z : pzval);
495495
ZVAL_NULL(z);
496496
Exit;
497497
end;
498-
// MessageBoxA(0, zend_pchar(AnsiString( TVarData(Value).VType.ToString)), '', 0 ) ;
498+
// MessageBoxA(0, zend_pchar(zend_ustr( TVarData(Value).VType.ToString)), '', 0 ) ;
499499
case TVarData(Value).VType of
500500
varString : //Peter Enz
501501
begin
@@ -513,7 +513,7 @@ procedure variant2zval(value : variant;var z : pzval);
513513
begin
514514
S := string(TVarData(Value).VUString);
515515

516-
ZVAL_STRING(z, zend_pchar(AnsiString(S)), true);
516+
ZVAL_STRING(z, zend_pchar(zend_ustr(S)), true);
517517
end;
518518

519519
varOleStr : //Peter Enz
@@ -604,7 +604,7 @@ procedure php_end_implicit_flush(TSRMLS_D : pointer);
604604
{$ENDIF}
605605

606606

607-
function LoadPHP(const DllFileName: AnsiString = PHPWin) : boolean;
607+
function LoadPHP(const DllFileName: zend_ustr = PHPWin) : boolean;
608608

609609
begin
610610
Result := false;
@@ -927,7 +927,7 @@ function GetFilesVariables : pzval;
927927
end;
928928

929929

930-
function FloatToValue(Value: Extended): AnsiString;
930+
function FloatToValue(Value: Extended): zend_ustr;
931931
var
932932
{$IFDEF VERSION12}
933933
c: WideChar;
@@ -944,7 +944,7 @@ function FloatToValue(Value: Extended): AnsiString;
944944
end;
945945
end;
946946

947-
function ValueToFloat(Value : AnsiString) : extended;
947+
function ValueToFloat(Value : zend_ustr) : extended;
948948
var
949949
{$IFDEF VERSION12}
950950
c: WideChar;
@@ -962,16 +962,52 @@ function ValueToFloat(Value : AnsiString) : extended;
962962
end;
963963

964964

965+
{$IFDEF Linux}
966+
function GetPHPVersion: TPHPFileInfo;
967+
begin
968+
969+
end;
970+
{$ELSE}
965971
function GetPHPVersion: TPHPFileInfo;
966972
var
967-
FileName: AnsiString;
973+
FileName: {$IFDEF PHP_UNICE}String{$ELSE}AnsiString{$ENDIF};
974+
InfoSize, Wnd: DWORD;
975+
VerBuf: Pointer;
976+
FI: PVSFixedFileInfo;
977+
VerSize: DWORD;
968978
begin
969979
Result.MajorVersion := 0;
970980
Result.MinorVersion := 0;
971981
Result.Release := 0;
972982
Result.Build := 0;
973983
FileName := PHPWin;
984+
{$IFDEF PHP_UNICE}
985+
InfoSize := GetFileVersionInfoSize(PWideChar(Filename), Wnd);
986+
{$ELSE}
987+
InfoSize := GetFileVersionInfoSizeA(PAnsiChar(FileName), Wnd);
988+
{$ENDIF}
989+
if InfoSize <> 0 then
990+
begin
991+
GetMem(VerBuf, InfoSize);
992+
try
993+
{$IFDEF PHP_UNICE}
994+
if GetFileVersionInfo(PWideChar(FileName), Wnd, InfoSize, VerBuf) then
995+
{$ELSE}
996+
if GetFileVersionInfoA(PAnsiChar(FileName), Wnd, InfoSize, VerBuf) then
997+
{$ENDIF}
998+
if VerQueryValue(VerBuf, '\', Pointer(FI), VerSize) then
999+
begin
1000+
Result.MajorVersion := HIWORD(FI.dwFileVersionMS);
1001+
Result.MinorVersion := LOWORD(FI.dwFileVersionMS);
1002+
Result.Release := HIWORD(FI.dwFileVersionLS);
1003+
Result.Build := LOWORD(FI.dwFileVersionLS);
1004+
end;
1005+
finally
1006+
FreeMem(VerBuf);
1007+
end;
1008+
end;
9741009
end;
1010+
{$ENDIF}
9751011

9761012
initialization
9771013
{$IFDEF PHP4DELPHI_AUTOLOAD}

Source/PHPCommon.pas

+21-21
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ EPHPErrorEx = class(Exception);
4646

4747
TPHPVariable = class(TCollectionItem)
4848
private
49-
FName : {$IFDEF PHP_UNICE}UTf8String{$ELSE}AnsiString{$ENDIF};
50-
FValue : {$IFDEF PHP_UNICE}UTf8String{$ELSE}AnsiString{$ENDIF};
49+
FName : zend_ustr;
50+
FValue : zend_ustr;
5151
function GetAsBoolean: boolean;
5252
function GetAsFloat: double;
5353
function GetAsInteger: integer;
@@ -59,11 +59,11 @@ TPHPVariable = class(TCollectionItem)
5959
public
6060
property AsInteger : integer read GetAsInteger write SetAsInteger;
6161
property AsBoolean : boolean read GetAsBoolean write SetAsBoolean;
62-
property AsString : {$IFDEF PHP_UNICE}UTf8String{$ELSE}AnsiString{$ENDIF} read FValue write FValue;
62+
property AsString : zend_ustr read FValue write FValue;
6363
property AsFloat : double read GetAsFloat write SetAsFloat;
6464
published
65-
property Name : {$IFDEF PHP_UNICE}UTf8String{$ELSE}AnsiString{$ENDIF} read FName write FName;
66-
property Value : {$IFDEF PHP_UNICE}UTf8String{$ELSE}AnsiString{$ENDIF} read FValue write FValue;
65+
property Name : zend_ustr read FName write FName;
66+
property Value : zend_ustr read FValue write FValue;
6767
end;
6868

6969
TPHPVariables = class(TCollection)
@@ -76,22 +76,22 @@ TPHPVariables = class(TCollection)
7676
public
7777
function Add: TPHPVariable;
7878
constructor Create(AOwner: TComponent);
79-
function GetVariables : AnsiString;
80-
function IndexOf(AName : AnsiString) : integer;
81-
procedure AddRawString(AString : AnsiString);
79+
function GetVariables : zend_ustr;
80+
function IndexOf(AName : zend_ustr) : integer;
81+
procedure AddRawString(AString : zend_ustr);
8282
property Items[Index: Integer]: TPHPVariable read GetItem write SetItem; default;
83-
function ByName(AName : AnsiString) : TPHPVariable;
83+
function ByName(AName : zend_ustr) : TPHPVariable;
8484
end;
8585

8686
TPHPConstant = class(TCollectionItem)
8787
private
88-
FName : AnsiString;
89-
FValue : AnsiString;
88+
FName : zend_ustr;
89+
FValue : zend_ustr;
9090
protected
9191
function GetDisplayName : string; override;
9292
published
93-
property Name : AnsiString read FName write FName;
94-
property Value : AnsiString read FValue write FValue;
93+
property Name : zend_ustr read FName write FName;
94+
property Value : zend_ustr read FValue write FValue;
9595
end;
9696

9797
TPHPConstants = class(TCollection)
@@ -104,7 +104,7 @@ TPHPConstants = class(TCollection)
104104
public
105105
function Add: TPHPConstant;
106106
constructor Create(AOwner: TComponent);
107-
function IndexOf(AName : AnsiString) : integer;
107+
function IndexOf(AName : zend_ustr) : integer;
108108
property Items[Index: Integer]: TPHPConstant read GetItem write SetItem; default;
109109
end;
110110

@@ -125,7 +125,7 @@ TPHPHeaders = class(TCollection)
125125
public
126126
function Add: TPHPHeader;
127127
constructor Create(AOwner: TComponent);
128-
function GetHeaders : AnsiString;
128+
function GetHeaders : zend_ustr;
129129
property Items[Index: Integer]: TPHPHeader read GetItem write SetItem; default;
130130
end;
131131

@@ -171,7 +171,7 @@ function TPHPVariables.GetOwner : TPersistent;
171171
Result := FOwner;
172172
end;
173173

174-
function TPHPVariables.GetVariables: AnsiString;
174+
function TPHPVariables.GetVariables: zend_ustr;
175175
var i : integer;
176176
begin
177177
for i := 0 to Count - 1 do
@@ -182,7 +182,7 @@ function TPHPVariables.GetVariables: AnsiString;
182182
end;
183183
end;
184184

185-
function TPHPVariables.IndexOf(AName: AnsiString): integer;
185+
function TPHPVariables.IndexOf(AName: zend_ustr): integer;
186186
var
187187
i : integer;
188188
begin
@@ -197,7 +197,7 @@ function TPHPVariables.IndexOf(AName: AnsiString): integer;
197197
end;
198198
end;
199199

200-
procedure TPHPVariables.AddRawString(AString : AnsiString);
200+
procedure TPHPVariables.AddRawString(AString : zend_ustr);
201201
var
202202
SL : TStringList;
203203
i : integer;
@@ -227,7 +227,7 @@ procedure TPHPVariables.AddRawString(AString : AnsiString);
227227
SL.Free;
228228
end;
229229

230-
function TPHPVariables.ByName(AName: AnsiString): TPHPVariable;
230+
function TPHPVariables.ByName(AName: zend_ustr): TPHPVariable;
231231
var
232232
i : integer;
233233
begin
@@ -359,7 +359,7 @@ function TPHPConstants.GetOwner: TPersistent;
359359
Result := FOwner;
360360
end;
361361

362-
function TPHPConstants.IndexOf(AName: AnsiString): integer;
362+
function TPHPConstants.IndexOf(AName: zend_ustr): integer;
363363
var
364364
i : integer;
365365
begin
@@ -408,7 +408,7 @@ function TPHPHeaders.GetOwner : TPersistent;
408408
Result := FOwner;
409409
end;
410410

411-
function TPHPHeaders.GetHeaders: AnsiString;
411+
function TPHPHeaders.GetHeaders: zend_ustr;
412412
var i : integer;
413413
begin
414414
for i := 0 to Count - 1 do

0 commit comments

Comments
 (0)