ingydotnet / yaml-libyaml-pm

Perl Binding to libyaml
http://search.cpan.org/dist/YAML-LibYAML/
33 stars 37 forks source link

String hex values are converted to integer #104

Open clintolsen opened 2 years ago

clintolsen commented 2 years ago

Hi, even though $YAML::XS::QuoteNumericStrings defaults to true, it doesn't dump this snippet correctly. The hex value should be quoted.

p Dump qw(a b 1 0x1234);
--- a
--- b
--- '1'
--- 0x1234
perlpunk commented 1 year ago

YAML::XS doesn't fully implement the YAML spec regarding types like numbers. It only considers numbers that look like numbers to perl. To fix it, we would have to write our own function to check if something is a number according to the spec. (Or resort to calling a perl regex). And then also the question is, to which spec. 1.1 or 1.2? Also it would be only available on request, not by default, to not break any existing code. I assume nobody has time currently to do this.