Andrea Faulds wrote on 27/11/2014 13:48:
On 27 Nov 2014, at 08:22, Stanislav Malyshev <smalys...@gmail.com> wrote:

Looking into this and also reading the \u{} proposal, I also thought -
do we have a programmatic way of doing what \u would do? I.e. if we
assume $x holds an Unicode codepoint value (i.e., an integer) do we have
a good built-in way to generate the corresponding utf8 sequence?
If not, then I think this class may be a good place to put such a
function in.
You mean something along the lines of JavaScript’s String.fromCharCode (or, in 
ES6, String.fromCodePoint)?

One of the nice things about that function is that it can take multiple codes. 
So I can do String.fromCodePoint(65, 66, 67) to get “ABC”.

If we add that, we should also have an analogue of JavaScript’s 
String.charCodeAt/String.codePointAt to do the operation in reverse.

We already have the single-byte versions: chr() and ord(). It's been on my to do list for a while to rewrite the manual pages for those, which currently have a whole lot of misleading references to ASCII.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to