summaryrefslogtreecommitdiff
path: root/mips/packages/fcl-json/src/jsonparser.pp
diff options
context:
space:
mode:
Diffstat (limited to 'mips/packages/fcl-json/src/jsonparser.pp')
-rw-r--r--mips/packages/fcl-json/src/jsonparser.pp32
1 files changed, 28 insertions, 4 deletions
diff --git a/mips/packages/fcl-json/src/jsonparser.pp b/mips/packages/fcl-json/src/jsonparser.pp
index 22726a79ad..2f03a92f0c 100644
--- a/mips/packages/fcl-json/src/jsonparser.pp
+++ b/mips/packages/fcl-json/src/jsonparser.pp
@@ -28,9 +28,12 @@ Type
TJSONParser = Class(TObject)
Private
FScanner : TJSONScanner;
+ FuseUTF8,
FStrict: Boolean;
function ParseNumber: TJSONNumber;
procedure SetStrict(const AValue: Boolean);
+ function GetUTF8 : Boolean;
+ procedure SetUTF8(const AValue: Boolean);
Protected
procedure DoError(const Msg: String);
function DoParse(AtCurrent,AllowEOF: Boolean): TJSONData;
@@ -42,11 +45,13 @@ Type
Property Scanner : TJSONScanner read FScanner;
Public
function Parse: TJSONData;
- Constructor Create(Source : TStream); overload;
- Constructor Create(Source : TJSONStringType); overload;
+ Constructor Create(Source : TStream; AUseUTF8 : Boolean = True); overload;
+ Constructor Create(Source : TJSONStringType; AUseUTF8 : Boolean = True); overload;
destructor Destroy();override;
// Use strict JSON: " for strings, object members are strings, not identifiers
Property Strict : Boolean Read FStrict Write SetStrict;
+ // if set to TRUE, then strings will be converted to UTF8 ansistrings, not system codepage ansistrings.
+ Property UseUTF8 : Boolean Read GetUTF8 Write SetUTF8;
end;
EJSONParser = Class(EParserError);
@@ -152,6 +157,23 @@ begin
end;
end;
+function TJSONParser.GetUTF8 : Boolean;
+
+begin
+ if Assigned(FScanner) then
+ Result:=FScanner.UseUTF8
+ else
+ Result:=FUseUTF8;
+end;
+
+procedure TJSONParser.SetUTF8(const AValue: Boolean);
+
+begin
+ FUseUTF8:=AValue;
+ if Assigned(FScanner) then
+ FScanner.UseUTF8:=FUseUTF8;
+end;
+
procedure TJSONParser.SetStrict(const AValue: Boolean);
begin
if (FStrict=AValue) then
@@ -250,16 +272,18 @@ begin
Raise EJSONParser.Create(S);
end;
-constructor TJSONParser.Create(Source: TStream);
+constructor TJSONParser.Create(Source: TStream; AUseUTF8 : Boolean = True);
begin
Inherited Create;
FScanner:=TJSONScanner.Create(Source);
+ UseUTF8:=AUseUTF8;
end;
-constructor TJSONParser.Create(Source: TJSONStringType);
+constructor TJSONParser.Create(Source: TJSONStringType; AUseUTF8 : Boolean = True);
begin
Inherited Create;
FScanner:=TJSONScanner.Create(Source);
+ UseUTF8:=AUseUTF8;
end;
destructor TJSONParser.Destroy();