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

Escape sequences for "invalid" characters #187

Open
shirok opened this issue Mar 20, 2016 · 2 comments
Open

Escape sequences for "invalid" characters #187

shirok opened this issue Mar 20, 2016 · 2 comments

Comments

@shirok
Copy link
Owner

shirok commented Mar 20, 2016

Since we added r7rs support, \x escape sequence in a string and a character literal is interpreted as unicode codepoint in r7rs compatible mode. It loses capability of writing raw octet value in the native encoding, when the native encoding is sjis or eucjp.

We can still use legacy mode to interpret \xNN as a raw octet, but for the better compatibility and read/write invariance, it might be better to introduce another escape sequence that specifically indicates raw octets. (It's especially important in incomplete string literals. Such raw octet representation allows writing portable incomplete string literal.)

Related: #185

@qykth-git
Copy link
Contributor

Here is my idea of those raw embedded octets.

\x and ; comes from R7RS, and *comes from incomplete string notation.
Last ; is required to split embedded octets and normal characters.
Use , to embed 2 or more octets at once.

;; one octet
"\x*1;" "\x*2;" "\x*a;" "\x*b;"
"\x*01;" "\x*02;" "\x*0a;" "\x*0b;"
"\x*01;\x*02;\x*03;"

;; multiple octets
"\x*1,2,3,4,a,b,c,d;"
"\x*01,23,34,ab,cd,ef;"

;; embed raw octets among normal charactors
"foo\x*ab,cd,1,2,3,04,05,06;bar"
"\x0041;\x61;\x*41,61;" ;; => "A", "a", embedded 0x41, embedded 0x61

;; long line concatenation
   "foo\x*ab,cd,\
    01,02,03,\
    ab,cd;bar"

;; those are all embedded 0x01
"\x*1;"
"\x*001;"
"\x*000001;"

;; error
"\x*1ff;" ;; error: octet exceeds 0xff

@shirok
Copy link
Owner Author

shirok commented Mar 20, 2016

I like it.

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

2 participants