Skip to content

fix: parse YAML 1.2 octal scalars (0o prefix) as integers#1451

Open
raphaelroshan wants to merge 1 commit into
jbeder:masterfrom
raphaelroshan:fix/1251-octal-scalars
Open

fix: parse YAML 1.2 octal scalars (0o prefix) as integers#1451
raphaelroshan wants to merge 1 commit into
jbeder:masterfrom
raphaelroshan:fix/1251-octal-scalars

Conversation

@raphaelroshan

@raphaelroshan raphaelroshan commented Jun 23, 2026

Copy link
Copy Markdown

Fixes #1251.

YAML 1.2 writes octal as 0o17, but as<int>() failed on it because std::stringstream's octal parsing only understands the C-style 0 prefix.

Normalize 0o/0O to a leading 0 before the stream conversion, so both the 1.1 (0123) and 1.2 (0o123) spellings decode. Hex and decimal are unchanged. As per the discussion in the issue, adding a function NormalizeOctalPrefix that should help to support backward compatibility. Added a test covering octal, signed/unsigned, hex and decimal.

Do let me know if i misinterpreted the behavior required!

@raphaelroshan raphaelroshan force-pushed the fix/1251-octal-scalars branch from 3331445 to 2ca3378 Compare June 23, 2026 15:44
@raphaelroshan raphaelroshan marked this pull request as ready for review June 23, 2026 16:30
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

Successfully merging this pull request may close these issues.

YAML octal scalars not converted to ints

1 participant