Dexed, revived!
Akira1364
operator97 at gmail.com
Wed Feb 26 03:10:30 UTC 2020
On Tuesday, 25 February 2020 at 21:45:04 UTC, Basile B. wrote:
> Yeah but did you try to load a goddamn JSON recipe that **has**
> the BOM written ?
> This stuff was there for a good reason you know ;)
The reason BOMs weren't working for you was because you were
using a TMemoryStream to actually load the JSON files, and
TMemoryStream is just a stream of raw bytes that knows absolutely
nothing about encodings.
All I had to do to get rid of your 30 lines of "BOM skipping"
code was change the file loading part to this:
```
List := TStringList.Create;
List.LoadFromFile(FFileName, TEncoding.UTF8);
Stream := TStringStream.Create(List.Text, TEncoding.UTF8, False);
List.Free;
Stream.Position := 0;
```
And then continue by creating the TJSONParser from `Stream`.
Doing it that way works correctly BOM or no BOM.
More information about the Digitalmars-d-ide
mailing list