Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML parser does not support escape sequences (e.g. "\u0000") #114

Open
dougwinsby opened this issue Dec 19, 2022 · 0 comments
Open

YAML parser does not support escape sequences (e.g. "\u0000") #114

dougwinsby opened this issue Dec 19, 2022 · 0 comments

Comments

@dougwinsby
Copy link

There does not appear to be any way to encode a double quote (") scalar value (or any special character) with this library.

The YAML specification allows special characters to be escaped in double-quoted scalar values.

Also, to escape a double quote, you should be able to include it in a single-quoted string:

'"'

But YAML also supports unicode hex characters using:

"\u0022"

If this library supported just this second method, any unicode character could be included (including a double quote).

For those looking for a work-around, we used a JSON parser from the Synopse (mORMot) library. The SynCommons.pas file is all you need. Here is an example of how it would work:

uses
  SynCommons;

function DecodeEscapeSequences(const s: string): string;
begin
  if s.Contains('\u') then
  begin
    var v := _json('{value:"' + RawUTF8(s) + '"}');
    result := v.value;
    Exit;
  end;
  result := s;
end;

Any JSON parser would probably work because the JSON standard supports these escape sequences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant