[php-langspec][Issue #233] - Unicode codepoints are used in the specification, but the specification does not define encoding
[email protected] Thu, 21 Feb 2019 20:09:50 +0000
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
You can view the Issue on github: https://github.com/php/php-langspec/issues/233 Comment by IMSoP: You are right that the specification makes mistakes about encodings, but you have it the wrong way around: PHP source is handled as Unicode, not as ASCII. You can prove this pretty easily, by [defining a function called 🐘](https://3v4l.org/TthsP). This clearly violates the [definition of a "name" in the current spec](https://github.com/php/php-langspec/blob/63375439ff7e8a1be93d0ef7d3c3b4833d5e35a0/spec/09-lexical-structure.md#names). A quick search finds two direct references to encoding in the existing text. First, [Section 9: Lexical Structure](https://github.com/php/php-langspec/blob/63375439ff7e8a1be93d0ef7d3c3b4833d5e35a0/spec/09-lexical-structure.md) specifies: > Step 1: Transformation, which converts a script from a particular character repertoire and encoding scheme into a sequence of 8-bit characters. and > Conforming implementations must accept scripts encoded with the UTF-8 encoding form (as defined by the Unicode standard), and transform them into a sequence of characters. Implementations can choose to accept and transform additional character encoding schemes. Secondly, Section 11, under [the `declare` statement](https://github.com/php/php-langspec/blob/197a397cf84bdcd3f896aebf15a73b5fd45a174d/spec/11-statements.md#the-declare-statement), explains *how* such encodings are selected: > encoding: character encoding can be specified on a script-by-script basis using the encoding directive. The joint ISO and IEC standard ISO/IEC 8859 standard series specifies a number of 8-bit-character encodings whose names can be used with this directive. This directive applies only to the file it appears in, and does not affect the included files. Both reference "8-bit characters", a somewhat odd term, which doesn't really make any sense. I'm not sure why there's any mention of 8-bit at all here, since I'm pretty sure `declare(encoding=UTF-16);` is also supported.