# [RFC] UString

- Thread: https://externals.io/message/78174
- Original archive: https://news-web.php.net/php.internals/78174
- Started by Joe Watkins on 2014-10-21T07:06:52+00:00
- Messages: 87
- Page 1 of 4: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/78174.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #78174 — Joe Watkins — 2014-10-21T07:06:52+00:00

URL: https://externals.io/message/78174#78174

Morning internalz,

	https://wiki.php.net/rfc/ustring

	This is the result of work done by a few of us, we won't be opening any
vote in a fortnight. We have a long time before 7, there is no rush
whatever.

	Now seems like a good time to start the conversation so we can hash out
the details, or get on with other things ;)

Cheers
Joe

---

## #78175 — Leigh — 2014-10-21T07:40:57+00:00

URL: https://externals.io/message/78174#78175 · In reply to: #78174

> Morning internalz,
>
>         https://wiki.php.net/rfc/ustring
>
>         This is the result of work done by a few of us, we won't be opening any
> vote in a fortnight. We have a long time before 7, there is no rush
> whatever.
>
>         Now seems like a good time to start the conversation so we can hash out
> the details, or get on with other things ;)
>

Breaks nothing, faster than mbstring, seems like win/win to me.

> On the flip side, implementing UString as a scalar object would be inconsistent. At time of writing, array, int, float, bool, etc have no implementation available for this.

I agree it shouldn't be a scalar object, but how about some operator
overloading like the GMP object has, so that you don't have to cast to
string for expected behaviour with type coercion etc.

> Right now there are user-space libraries out there that cover a lot more functionality than UString.

Do you need help implementing these? Do you think it would be
beneficial to briefly list which areas need attention on the RFC, so
they can be checked off over time?

Overall +1 on the concept.

---

## #78176 — Zeev Suraski — 2014-10-21T07:50:14+00:00

URL: https://externals.io/message/78174#78176 · In reply to: #78174

> -----Original Message-----
> From: Joe Watkins [mailto:pthreads@pthreads.org]
> Sent: Tuesday, October 21, 2014 10:07 AM
> To: internals@lists.php.net
> Subject: [PHP-DEV] [RFC] UString
>
> Morning internalz,
>
> 	https://wiki.php.net/rfc/ustring
>
> 	This is the result of work done by a few of us, we won't be opening
> any vote in a fortnight. We have a long time before 7, there is no rush
> whatever.
>
> 	Now seems like a good time to start the conversation so we can
> hash out the details, or get on with other things ;)

+1 from me.  I think it's the right way to tackle Unicode.

Zeev

---

## #78178 — Joe Watkins — 2014-10-21T08:01:55+00:00

URL: https://externals.io/message/78174#78178 · In reply to: #78175

> 
> > […]
> 
> Breaks nothing, faster than mbstring, seems like win/win to me.
> 
> > […]
> 
> I agree it shouldn't be a scalar object, but how about some operator
> overloading like the GMP object has, so that you don't have to cast to
> string for expected behaviour with type coercion etc.
> 
> > […]
> 
> Do you need help implementing these? Do you think it would be
> beneficial to briefly list which areas need attention on the RFC, so
> they can be checked off over time?
> 
> Overall +1 on the concept.

Morning Leigh,

ZEND_CONCAT is overloaded, as well as read_dimension and cast (to
string) handlers. This seems to cover everything, unless I missed
something ?

Cheers
Joe

---

## #78179 — Lester Caine — 2014-10-21T08:02:20+00:00

URL: https://externals.io/message/78174#78179 · In reply to: #78174

> Now seems like a good time to start the conversation so we can hash out
> the details, or get on with other things ;)

Does this address the problem of sorting array keys using a particular
language or collation?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #78180 — Joe Watkins — 2014-10-21T08:26:42+00:00

URL: https://externals.io/message/78174#78180 · In reply to: #78179

> 
> > […]
> 
> Does this address the problem of sorting array keys using a particular
> language or collation?
> 
> -- 
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk
> Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
> 

No.

Cheers
Joe

---

## #78182 — Nicolas Grekas — 2014-10-21T08:48:33+00:00

URL: https://externals.io/message/78174#78182 · In reply to: #78174

This is great thanks for the work!
I think we should have an opinion on grapheme clusters and tell about it in
the RFC.

I do support the idea that PHP users need to handle "characters" in term of
"graphemes". We need a core way to deal with code points of course, but
things like "reverse" have very low value without graphemes.

toLower/toUpper also misses the turkish specifics - or is the Ustring class
"locale" dependent?
Should we add "toCaseFold"? Where are the "i" version of strpos, etc. Do we
want them in core PHP7? An other point we should add to the RFC.

For reference here is my grapheme cluster aware string handling:
https://github.com/nicolas-grekas/Patchwork-UTF8/blob/master/class/Patchwork/Utf8.php

and the same but turkish variant:
https://github.com/nicolas-grekas/Patchwork-UTF8/blob/master/class/Patchwork/TurkishUtf8.php

About unicode equivalence:
For all the string matching functions (contains, startsWith, etc.) do they
handling unicode equivalence?
How do we compare two Ustrings? Does the == operator handle unicode
equivalence? What is the way to go otherwise? Normalize is before on our
own?
The RFC should tell about it also IMHO (and tell that collation/sorting
handling is out of scope).

Complex topic :)

Cheers,
NIcolas

---

## #78183 — Dmitry Stogov — 2014-10-21T09:01:23+00:00

URL: https://externals.io/message/78174#78183 · In reply to: #78174

Hi Joe,

As an extension it looks fine.
I assume, you don't propose to use UString objects in engine and other
extensions.
Unfortunately, it's yet another incomplete solution.

It won't allow Unicode strings as array keys;
concatenation using "." (probably may be done),
no auto-conversion from/to script/output encoding,
no auto-conversion of strings coming from database extensions, etc

The "right" approach, would be extending zend_string with "encoding" and
then adopting near all functions working with zend_string to take
"encoding" into account. But, of course, this is going to lead to much more
complicated solution (with some slowdown).

If we don't care about complete solution, UString proposal may make sense
at lest as a faster replacement of ext/mbstring.

Thanks. Dmitry.





> Morning internalz,
>
>         https://wiki.php.net/rfc/ustring
>
>         This is the result of work done by a few of us, we won't be
> opening any
> vote in a fortnight. We have a long time before 7, there is no rush
> whatever.
>
>         Now seems like a good time to start the conversation so we can
> hash out
> the details, or get on with other things ;)
>
> Cheers
> Joe

---

## #78184 — Leigh — 2014-10-21T09:14:35+00:00

URL: https://externals.io/message/78174#78184 · In reply to: #78178

>
> ZEND_CONCAT is overloaded, as well as read_dimension and cast (to
> string) handlers. This seems to cover everything, unless I missed
> something ?
>

ZEND_CONCAT and ZEND_ASSIGN_CONCAT were my primary concerns, I didn't
see any mention of these in the RFC which is why I brought it up
(maybe it should be documented there).

May not be desirable at all, but obviously with ordinary strings we
can do `int + "str containing int"`, and if the UString object
contains an int then `int + (string)ustring` will still achieve that.

My thought was to make the remaining operators that don't make sense
on an object implicitly cast to string before the operation takes
place.

Feel free to "do not want". :)

---

## #78186 — Philip Hofstetter — 2014-10-21T09:19:54+00:00

URL: https://externals.io/message/78174#78186 · In reply to: #78183

Hello

Tangentially related:


>
>
> It won't allow Unicode strings as array keys;


I wish there was a way for specific objects to opt into this.

Using __toString()  we have something that mostly behaves just like a
string and can be used wherever a string is required - with the exception
of array keys.

I seem to remember some earlier discussion that led to this being
intentionally made impossible (and I understand why), but maybe there could
be support for another magic underscore method that's called when an object
is about to be put into an array as a key (or similar situations)

Philip


-- 
Sensational AG
Giesshübelstrasse 62c, Postfach 1966, 8021 Zürich
Tel. +41 43 544 09 60, Mobile  +41 79 341 01 99
info@sensational.ch, http://www.sensational.ch

---

## #78187 — Florian Margaine — 2014-10-21T09:23:30+00:00

URL: https://externals.io/message/78174#78187 · In reply to: #78186

Hi,

@Philip: please read the discussion that happened a month ago (and follow
up on it if necessary):
http://marc.info/?l=php-internals&m=141145952422734&w=2

Regards,

On Tue, Oct 21, 2014 at 11:19 AM, Philip Hofstetter <
phofstetter@sensational.ch> wrote:

> Hello
>
> Tangentially related:
>
> 
> > […]
>
>
> I wish there was a way for specific objects to opt into this.
>
> Using __toString()  we have something that mostly behaves just like a
> string and can be used wherever a string is required - with the exception
> of array keys.
>
> I seem to remember some earlier discussion that led to this being
> intentionally made impossible (and I understand why), but maybe there could
> be support for another magic underscore method that's called when an object
> is about to be put into an array as a key (or similar situations)
>
> Philip
>
>
> --
> Sensational AG
> Giesshübelstrasse 62c, Postfach 1966, 8021 Zürich
> Tel. +41 43 544 09 60, Mobile  +41 79 341 01 99
> info@sensational.ch, http://www.sensational.ch
>



-- 
Florian Margaine

---

## #78188 — Joe Watkins — 2014-10-21T09:25:49+00:00

URL: https://externals.io/message/78174#78188 · In reply to: #78183

> Hi Joe,
> 
> 
> As an extension it looks fine.
> 
> I assume, you don't propose to use UString objects in engine and other
> extensions.

I'm not proposing it now, no.

> Unfortunately, it's yet another incomplete solution.
> 
> It won't allow Unicode strings as array keys;

The engine doesn't allow that, couldn't we find a way of using objects
as array keys ?? It doesn't seem like a limitation of the extension, to
me ;)

> concatenation using "." (probably may be done),

That's already done.

> no auto-conversion from/to script/output encoding,

That could be arranged.

> no auto-conversion of strings coming from database extensions, etc

I'm not sure how important that is, it's not a big deal to create a new
object, nor would it be a big deal for those extensions that need to
always return unicode strings to do so.
> 
> The "right" approach, would be extending zend_string with "encoding"
> and then adopting near all functions working with zend_string to take
> "encoding" into account. But, of course, this is going to lead to much
> more complicated solution (with some slowdown).

That seems a lot like bashing our head against a wall. We tried to
introduce support everywhere and it fails. Do we really want to step on
the performance gains introduced by recent changes by making all strings
unicode ?

That doesn't seem like a sensible thing to want, at least right now.

Having UString doesn't stop us approaching the problem differently in
the future, but it would have to be a very different future to even make
sense to me.

> If we don't care about complete solution, UString proposal may make
> sense at lest as a faster replacement of ext/mbstring.

As the RFC states, we are only approaching one problem, the problem that
ext/mbstring is not a good API.
> 
> Thanks. Dmitry.


> On Tue, Oct 21, 2014 at 11:06 AM, Joe Watkins <pthreads@pthreads.org>
> wrote:
>         Morning internalz,
>         
>                 https://wiki.php.net/rfc/ustring
>         
>                 This is the result of work done by a few of us, we
>         won't be opening any
>         vote in a fortnight. We have a long time before 7, there is no
>         rush
>         whatever.
>         
>                 Now seems like a good time to start the conversation
>         so we can hash out
>         the details, or get on with other things ;)
>         
>         Cheers
>         Joe
>         
>         
>         --
>         
>         

Cheers
Joe

---

## #78189 — Robert Stoll — 2014-10-21T09:48:53+00:00

URL: https://externals.io/message/78174#78189 · In reply to: #78174

Hi Joe,

I have not devoted myself to unicode and thus cannot give you a feedback on your implementation.
Nevertheless, I was wondering whether string interpolation is still supported by your solution (couldn't find anything in the RFC about it but maybe you thought that is implicit given).

Cheers,
Robert

> -----Ursprüngliche Nachricht-----
> Von: Joe Watkins [mailto:pthreads@pthreads.org]
> Gesendet: Dienstag, 21. Oktober 2014 09:07
> An: internals@lists.php.net
> Betreff: [PHP-DEV] [RFC] UString
> 
> Morning internalz,
> 
> 	https://wiki.php.net/rfc/ustring
> 
> 	This is the result of work done by a few of us, we won't be opening any vote in a fortnight. We have a long time
> before 7, there is no rush whatever.
> 
> 	Now seems like a good time to start the conversation so we can hash out the details, or get on with other things ;)
> 
> Cheers
> Joe

---

## #78190 — Dmitry Stogov — 2014-10-21T09:52:19+00:00

URL: https://externals.io/message/78174#78190 · In reply to: #78188

> 
> > […]
>
> I'm not proposing it now, no.
>
> > […]
>
> The engine doesn't allow that, couldn't we find a way of using objects
> as array keys ?? It doesn't seem like a limitation of the extension, to
> me ;)
>
> > […]
>
> That's already done.
>
> > […]
>
> That could be arranged.
>
> > […]
>
> I'm not sure how important that is, it's not a big deal to create a new
> object, nor would it be a big deal for those extensions that need to
> always return unicode strings to do so.
> > […]
>
> That seems a lot like bashing our head against a wall. We tried to
> introduce support everywhere and it fails. Do we really want to step on
> the performance gains introduced by recent changes by making all strings
> unicode ?
>

Yeah :)
I'm not sure, if it should be done, and I don't like to work on it in the
nearest future, but zend_string approach should be easier to implement than
separate IS_UNICODE + IS_STRING + IS_BINARY types in PHP6.


> That doesn't seem like a sensible thing to want, at least right now.
>
> Having UString doesn't stop us approaching the problem differently in
> the future, but it would have to be a very different future to even make
> sense to me.
>

Agree.


>
> > […]
>
> As the RFC states, we are only approaching one problem, the problem that
> ext/mbstring is not a good API.
>

Then, it's fine.

One note regarding implementation: why do you use C++ for ustring.cpp? I
understand it's necessary for ICU backend, but if in the future you might
switch to another backend (and it may not require C++) why to use C++ for
PHP extension part?

Thanks. Dmitry.


> > […]
>
>
> > […]
>
> Cheers
> Joe

---

## #78191 — Joe Watkins — 2014-10-21T10:04:27+00:00

URL: https://externals.io/message/78174#78191 · In reply to: #78189

> Hi Joe,
> 
> I have not devoted myself to unicode and thus cannot give you a feedback on your implementation.
> Nevertheless, I was wondering whether string interpolation is still supported by your solution (couldn't find anything in the RFC about it but maybe you thought that is implicit given).
> 
> Cheers,
> Robert
> 
> > […]
> 
> 

I did think implied, the extension readme mentions casting, I'll mention
in the RFC ... 

Cheers
Joe

---

## #78192 — Joe Watkins — 2014-10-21T10:13:21+00:00

URL: https://externals.io/message/78174#78192 · In reply to: #78190

> 
> 
> On Tue, Oct 21, 2014 at 1:25 PM, Joe Watkins <pthreads@pthreads.org>
> wrote:
>         
> > […]
>         and other
> > […]
>         
>         I'm not proposing it now, no.
>         
> > […]
>         
>         The engine doesn't allow that, couldn't we find a way of using
>         objects
>         as array keys ?? It doesn't seem like a limitation of the
>         extension, to
>         me ;)
>         
> > […]
>         
>         That's already done.
>         
> > […]
>         
>         That could be arranged.
>         
> > […]
>         extensions, etc
>         
>         I'm not sure how important that is, it's not a big deal to
>         create a new
>         object, nor would it be a big deal for those extensions that
>         need to
>         always return unicode strings to do so.
> > […]
>         "encoding"
> > […]
>         zend_string to take
> > […]
>         lead to much
> > […]
>         
>         That seems a lot like bashing our head against a wall. We
>         tried to
>         introduce support everywhere and it fails. Do we really want
>         to step on
>         the performance gains introduced by recent changes by making
>         all strings
>         unicode ?
> 
> 
> Yeah :)

You must like punishment :D
> 
> I'm not sure, if it should be done, and I don't like to work on it in
> the nearest future, but zend_string approach should be easier to
> implement than separate IS_UNICODE + IS_STRING + IS_BINARY types in
> PHP6.
> 
The implementation might be simpler, but the effect the same I think.

I can be wrong, but nothing has so drastically changed that will allow
us to absorb the kind of impact I think you are talking about.

>  
> 
>         That doesn't seem like a sensible thing to want, at least
>         right now.
>         
>         Having UString doesn't stop us approaching the problem
>         differently in
>         the future, but it would have to be a very different future to
>         even make
>         sense to me.
> 
> 
> Agree.
>  
> 
>         
> > […]
>         may make
> > […]
>         
>         As the RFC states, we are only approaching one problem, the
>         problem that
>         ext/mbstring is not a good API.
> 
> 
> Then, it's fine.
> 
> One note regarding implementation: why do you use C++ for ustring.cpp?
> I understand it's necessary for ICU backend, but if in the future you
> might switch to another backend (and it may not require C++) why to
> use C++ for PHP extension part? 

Totally possible that we'll have to change, or that we should change. A
few people have said they would like to write a backend so we'll see
what comes in and where that leads us.


> 
> Thanks. Dmitry.
>  
> 
> > […]
>         
>         
> > […]
>         <pthreads@pthreads.org>
> > […]
>         us, we
> > […]
>         there is no
> > […]
>         conversation
> > […]
>         
>         Cheers
>         Joe


Cheers
Joe

---

## #78193 — Lester Caine — 2014-10-21T10:19:51+00:00

URL: https://externals.io/message/78174#78193 · In reply to: #78190

> > […]
> Yeah :)
> I'm not sure, if it should be done, and I don't like to work on it in the
> nearest future, but zend_string approach should be easier to implement than
> separate IS_UNICODE + IS_STRING + IS_BINARY types in PHP6.

Isn't this the first discussion?

If we are going down the root of keeping PHP7 as ascii only in the core,
then ustring probably makes sense, but it does not address many of the
areas where unicode is really needed. Handling unicode content outside
the core is working reasonably at the moment, it is the problems such as
using unicode keys for arrays which is the main area where unicoe is
needed in PHP7 and so a more embedded handling is needed which may cut
across yet another content wrapper?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #78195 — Matteo Beccati — 2014-10-21T10:50:17+00:00

URL: https://externals.io/message/78174#78195 · In reply to: #78174

> Morning internalz,
> 
> 	https://wiki.php.net/rfc/ustring
> 
> 	This is the result of work done by a few of us, we won't be opening any
> vote in a fortnight. We have a long time before 7, there is no rush
> whatever.
> 
> 	Now seems like a good time to start the conversation so we can hash out
> the details, or get on with other things ;)

Nice job!

However, doesn't ICU use UTF-16 by default which is undesirable as most
of the times it requires converting from and to UTF-8?


Cheers
-- 
Matteo Beccati

Development & Consulting - http://www.beccati.com/

---

## #78196 — Rowan Collins — 2014-10-21T11:11:33+00:00

URL: https://externals.io/message/78174#78196 · In reply to: #78193

Lester Caine wrote (on 21/10/2014):
> If we are going down the root of keeping PHP7 as ascii only in the core,
> then ustring probably makes sense, but it does not address many of the
> areas where unicode is really needed.

Just a quick point: most of the core is not ASCII. PHP strings are byte 
strings, completely divorced from any encoding. A few native functions 
assume ISO8859-1 (or possibly Windows CP1252), but mostly they just 
juggle which ever bytes you give them.

The main exception I can think of is that numbers are often handled 
specially, with digits and separators as defined by ASCII. But since 
we're talking UTF-8, that doesn't need to change.

> Handling unicode content outside
> the core is working reasonably at the moment, it is the problems such as
> using unicode keys for arrays which is the main area where unicoe is
> needed in PHP7 and so a more embedded handling is needed which may cut
> across yet another content wrapper?

I do think this is an important thing to consider, though. If this 
extension is genuinely just meant as a more modern and more performant 
way of doing things which mbstring and intl can already do, that needs 
to be clear in the way it's documented and publicised. If this gets 
publicised as "better Unicode support", users are naturally going to 
expect UString objects to start appearing in core, and in other 
extensions, and be disappointed that it's still just a toolbox for their 
own string handling.

-- 
Rowan Collins
[IMSoP]

---

## #78197 — Lester Caine — 2014-10-21T11:31:12+00:00

URL: https://externals.io/message/78174#78197 · In reply to: #78196

> Lester Caine wrote (on 21/10/2014):
> > […]
> 
> Just a quick point: most of the core is not ASCII. PHP strings are byte
> strings, completely divorced from any encoding. A few native functions
> assume ISO8859-1 (or possibly Windows CP1252), but mostly they just
> juggle which ever bytes you give them.
> 
> The main exception I can think of is that numbers are often handled
> specially, with digits and separators as defined by ASCII. But since
> we're talking UTF-8, that doesn't need to change.

Pierre had proposed restricting that to ascii as a way of addressing the
inconsistencies that arise because some areas do not currently make a
distinction.

> > […]
> 
> I do think this is an important thing to consider, though. If this
> extension is genuinely just meant as a more modern and more performant
> way of doing things which mbstring and intl can already do, that needs
> to be clear in the way it's documented and publicised. If this gets
> publicised as "better Unicode support", users are naturally going to
> expect UString objects to start appearing in core, and in other
> extensions, and be disappointed that it's still just a toolbox for their
> own string handling.

This is where a proper discussion on just what is trying to be achieved
is important, before discussing tangents?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #78198 — Christian Schneider — 2014-10-21T12:35:15+00:00

URL: https://externals.io/message/78174#78198 · In reply to: #78174

Am 21.10.2014 um 09:06 schrieb Joe Watkins <pthreads@pthreads.org>:
> 	https://wiki.php.net/rfc/ustring
> 
> 	This is the result of work done by a few of us, we won't be opening any
> vote in a fortnight. We have a long time before 7, there is no rush
> whatever.


I have one concern I want to bring up: The RFC proposes a helper function u() to generate UStrings.

As this is a very handy function name for all sort of utility functions (as a matter of face we use it to create and sanitize URL strings to be embedded into HTML) I would assume that more than one project has a name clash there.

Maybe something like _u() could be used instead? Or do you have better alternatives for this?

PS: UString is also in the global name space but should be less of a problem I'd imagine.

Regards,
- Chris

---

## #78199 — Michael Wallner — 2014-10-21T12:51:34+00:00

URL: https://externals.io/message/78174#78199 · In reply to: #78198

> Am 21.10.2014 um 09:06 schrieb Joe Watkins <pthreads@pthreads.org>:
> > […]
> opening any
> > […]
>
>
> I have one concern I want to bring up: The RFC proposes a helper function
> u() to generate UStrings.
>
> As this is a very handy function name for all sort of utility functions
> (as a matter of face we use it to create and sanitize URL strings to be
> embedded into HTML) I would assume that more than one project has a name
> clash there.
>
> Maybe something like _u() could be used instead? Or do you have better
> alternatives for this?
>
> PS: UString is also in the global name space but should be less of a
> problem I'd imagine.
>

With the "use function" support, that could be located in a namespace.

But something else: wasn't there a big concern in another thread regarding
codepoint/grapheme support, like with $ustring->length()?


-- 
Regards,
Mike

---

## #78200 — Andrea Faulds — 2014-10-21T13:38:34+00:00

URL: https://externals.io/message/78174#78200 · In reply to: #78198

> 
> 
> I have one concern I want to bring up: The RFC proposes a helper function u() to generate UStrings.
> 
> As this is a very handy function name for all sort of utility functions (as a matter of face we use it to create and sanitize URL strings to be embedded into HTML) I would assume that more than one project has a name clash there.
> 
> Maybe something like _u() could be used instead? Or do you have better alternatives for this?
> 
> PS: UString is also in the global name space but should be less of a problem I'd imagine.

I think we should reserve some way to do Unicode strings. I’d want u”foo”, but we’re not adding literals, so u(“foo”) it is.

Also, bear in mind that namespaces mean you can still have your own u() if it’s in your namespace (\u).
--
Andrea Faulds
http://ajf.me/

---

## #78201 — Andrea Faulds — 2014-10-21T13:45:28+00:00

URL: https://externals.io/message/78174#78201 · In reply to: #78174

So, one thing which I think is worth bringing up is code points vs. characters/graphemes.

This came up in another recent thread about Unicode on internals. While code-point manipulation is all well and good, we also need grapheme manipulation functions. Could we add these? That would make the API more useful.

On that note, ->charAt ought to be ->codepointAt to avoid being misleading.
--
Andrea Faulds
http://ajf.me/

---

## #78202 — Matteo Beccati — 2014-10-21T13:52:50+00:00

URL: https://externals.io/message/78174#78202

> 
> > […]
> 
> http:// userguide.icu-project.org/strings/utf-8
> It is interesting that the earlier adoption of UTF-16 still prevails,
> but switching to UTF-8 is becoming the norm?

Yes, as far as I knew using UTF-8 by default was a compile-time option
for ICU, that most of the times comes from system packages.


Cheers
-- 
Matteo Beccati

Development & Consulting - http://www.beccati.com/

---

Next page: https://externals.io/message/78174.md?page=2
