JsonConf: skip UTF8 BOM on reading file
Original Reporter info from Mantis: Alextpp @Alexey-T1
-
Reporter name: CudaText man
Original Reporter info from Mantis: Alextpp @Alexey-T1
- Reporter name: CudaText man
Description:
Patch allows to read JSON files with UTF8 BOM marker.
I tested this on demo, attached demo with included JSON lib with my changes.
Changes --
procedure SkipStreamBOM(S: TStream); Var OldPos : integer; Header : array[0..3] of byte; begin OldPos := S.Position; FillChar(Header, SizeOf(Header), 0); if S.Read(Header, 3) = 3 then if (Header[0]=$EF) and (Header[1]=$BB) and (Header[2]=$BF) then exit; S.Position := OldPos; end; procedure TJSONConfig.LoadFromStream(S: TStream); Var P : TJSONParser; J : TJSONData; begin SkipStreamBOM(S); P:=TJSONParser.Create(S,FJSONOptions); try ....
Mantis conversion info:
- Mantis ID: 38607
- Version: 3.3.1
- Fixed in version: 3.2.1
- Fixed in revision: 48926 (#b4d37f78)
- Target version: 4.0.0