Skip to content

Add \xHH Unicode escape code to basic strings#796

Merged
pradyunsg merged 4 commits intotoml-lang:mainfrom
eksortso:unicode_escapes
Jul 30, 2022
Merged

Add \xHH Unicode escape code to basic strings#796
pradyunsg merged 4 commits intotoml-lang:mainfrom
eksortso:unicode_escapes

Conversation

@eksortso
Copy link
Copy Markdown
Contributor

Per a conversation in #622, this PR adds a two-character \x escape code sequence for the first 256 Unicode code points. This provides a short explicit sequence for, among other code points: ASCII characters, certain control characters, and whitespace characters such as tab (\x09) and space (\x20) that need visible representation without resorting to longer \u and \U codes. Such sequences are commonly found in languages that also support the \u and \U codes for Unicode.

This PR replaces #709 and is intended for a post-v1.0.0 version of the TOML standard.

@marzer
Copy link
Copy Markdown
Contributor

marzer commented Nov 5, 2021

@pradyunsg Where did we land with this? It seems like a friction-free addition to the language (and one that would bring TOML in line with many other languages which also support \x). It's also practically free for implementers since the code paths that would already be handling \u and \U can be trivially extended to support \x.

@pradyunsg
Copy link
Copy Markdown
Member

Yea, let's do this.

@marzer
Copy link
Copy Markdown
Contributor

marzer commented Nov 16, 2021

@eksortso Do you have time to update this PR against the current master? If not I'm happy to fork your changes and look after it.

@eksortso
Copy link
Copy Markdown
Contributor Author

I'll update it later this evening.

@marzer
Copy link
Copy Markdown
Contributor

marzer commented Nov 17, 2021

Awesome, thanks @eksortso

@eksortso
Copy link
Copy Markdown
Contributor Author

@marzer I think that's got it.

@eksortso
Copy link
Copy Markdown
Contributor Author

The second change to CHANGELOG.md dresses up the bare URL for toml.io, just to appease the linter. I'll undo it if necessary.

@eksortso
Copy link
Copy Markdown
Contributor Author

eksortso commented May 3, 2022

For some reason I'd thought this had already been taken care of. It's up to date again.

@marzer @pradyunsg Care to take look at it?

Copy link
Copy Markdown
Contributor

@ChristianSi ChristianSi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good otherwise!

Comment thread CHANGELOG.md Outdated
@eksortso
Copy link
Copy Markdown
Contributor Author

eksortso commented Jun 6, 2022

@pradyunsg Any updates on this? Is the issue with pre-commit.ci impeding merges? Or are you planning a larger roadmap for the next release of TOML?

@pradyunsg pradyunsg merged commit 61ad52a into toml-lang:main Jul 30, 2022
@eksortso eksortso deleted the unicode_escapes branch July 30, 2022 15:42
@pradyunsg
Copy link
Copy Markdown
Member

Thanks @eksortso! ^>^

nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 4, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 4, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 4, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 4, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 4, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 5, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 5, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 5, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
nikitabobko added a commit to nikitabobko/TOMLDecoder that referenced this pull request Feb 5, 2026
toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12
dduan pushed a commit to dduan/TOMLDecoder that referenced this pull request Feb 5, 2026
* Update the code generator to match the formatting of ./Scripts/format.sh

* Reformat the code

This commit is a result of `./Scripts/format.sh`

* Fix file name mistake in the header of Generated swift files

The file is called Scripts/generate-tests.py not
Scripts/sync_compliance_tests.py

* Prefactoring: get rid of magic constant 8

This prefactoring will be important in later commits when I add support
for optional seconds (TOML 1.1.0) cause it won't longer be constant 8
but either 8 or 5 (depending on wheter the seconds are presented or not)

The magic constant 8 comes from scanTime where in case of success (not
nil value is returned) the total increment to the index variable equals
to 8

* Bump toml-test

None of the tests are failing after the bump

* Bump toml-test spec version 1.0.0 -> 1.1.0

The following tests are failing now:

    􀢄  Test "[inline-table] newline" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  (Line 3) Syntax error: newline not allowed in inline table.
    􀢄  Test "[spec-1.1.0] common 29" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  (Line 1) Syntax error: extra chars after value.
    􀢄  Test "[string] hex escape" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  Illegal escape character 'x'.
    􀢄  Test "[spec-1.1.0] common 12" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  Illegal escape character 'x'.
    􀢄  Test "[spec-1.1.0] common 47" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  (Line 4) Syntax error: newline not allowed in inline table.
    􀢄  Test "[string] escape esc" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  Illegal escape character 'e'.
    􀢄  Test "[datetime] no seconds" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  (Line 2) Syntax error: extra chars after value.
    􀢄  Test "[spec-1.1.0] common 34" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  (Line 1) Syntax error: extra chars after value.
    􀢄  Test "[spec-1.1.0] common 31" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  (Line 1) Syntax error: extra chars after value.
    􀢄  Test "[inline-table] newline" failed after 0.014 seconds with 1 issue.
    􀢄  Test "[spec-1.1.0] common 29" failed after 0.016 seconds with 1 issue.
    􀢄  Test "[string] hex escape" failed after 0.017 seconds with 1 issue.
    􀢄  Test "[spec-1.1.0] common 12" failed after 0.017 seconds with 1 issue.
    􀢄  Test "[inline-table] newline comment" recorded an issue at TOMLComplianceSupport.swift:34:25: Issue recorded
    􀄵  (Line 4) Syntax error: newline not allowed in inline table.
    􀢄  Test "[spec-1.1.0] common 47" failed after 0.019 seconds with 1 issue.
    􀢄  Test "[string] escape esc" failed after 0.019 seconds with 1 issue.
    􀢄  Test "[datetime] no seconds" failed after 0.021 seconds with 1 issue.
    􀢄  Test "[spec-1.1.0] common 34" failed after 0.025 seconds with 1 issue.
    􀢄  Test "[spec-1.1.0] common 31" failed after 0.026 seconds with 1 issue.
    􀢄  Test "[inline-table] newline comment" failed after 0.031 seconds with 1 issue.
    􀢄  Suite TOMLValidationTests failed after 0.041 seconds with 10 issues.
    􀢄  Test run with 743 tests in 8 suites failed after 0.550 seconds with 10 issues.

I will fix the tests in the next couple of commits

* TOML 1.1.0: Allow newlines and trailing commas in inline tables

toml-lang/toml#904

This commit fixes the following tests:
- [inline-table] newline
- [inline-table] newline comment

* TOML 1.1.0: Seconds in datetime and time values are now optional

toml-lang/toml#894

This commit fixes the following tests:
- [spec-1.1.0] common 34
- [spec-1.1.0] common 29
- [spec-1.1.0] common 31
- [datetime] no seconds

* TOML 1.1.0: Support \e escape for the escape character

toml-lang/toml#790

This commit fixes the following test:
- [string] escape esc

* TOML 1.1.0: Support \xHH notation to basic strings for codepoints <255

toml-lang/toml#796

This commit fixes all the remaining TOML 1.1.0 tests, namely:
- [string] hex escape
- [spec-1.1.0] common 12

* Docs: Now, we fully implement TOML 1.1.0
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.

5 participants