Re: [RFC] Unicode Escape Syntax
| From: | Stanislav Malyshev | Date: | Thu, 27 Nov 2014 08:21:03 +0000 |
| Subject: | Re: [RFC] Unicode Escape Syntax | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79216@lists.php.net to get a copy of this message | ||
Hi!
> I'm not completely against it. It's just an incomplete solution.
>
> echo "\u{1F602}"; // won't output 😂 if the output encoding is not UTF-8
You can always use iconv/recode to bring it to every encoding you need
(provided it supports full unicode range). I see this as a readability
feature - you can look up 1F602 but it's much harder to understand
what's going on if you have \xF0\x9F\x98\x82 instead. Of course, using
this in non-UTF-8 strings is useless, but my question would be - why
would you code have non-utf8 text literals? I mean, even if you output
in other format - why not use de-facto standard internally? Of course,
there might be legacy reasons - but then one won't use \u.
As an alternative, we may have \u{} which produces utf-8 and another one
which produces current script encoding (and errors out if this code
point is not part of it).
--
Stas Malyshev
smalyshev@gmail.com