krakjoe / ustring

UnicodeString for PHP7
Other
64 stars 7 forks source link

Feature safity for non unicode strings #15

Open marc-mabe opened 10 years ago

marc-mabe commented 10 years ago

I would like to see the API more feature safe to other encodings/charsets.

$german = new UString("T\xD4st", 'ISO-8859-15');

Thoughts?

hikari-no-yume commented 10 years ago

It's Unicode underneath... it should stay UString :/

krakjoe commented 10 years ago

This is confusing, please clarify what you mean @marc-mabe ?

marc-mabe commented 10 years ago

As I understand correctly this extension provides a string object currently usable for unicode strings. That's fine!

To provide this you have a string class that gets a scalar string and a unicode encoding on instantiation.

For me it already has all API-side requirements to support non unicode encodings, too. Sure it's theory and it's currently not required to finish the goal but as PHP developer you have to deal with other encodings from time to time (non unicode, non ascii). In this case you have to use mbstring/iconv anyway and this nice extension class UString can't be used only because it handles only unicode strings by definition.

I think it could be really helpful in the future to have a more generalized API to make it possible to implement handing of non unicode encodings without BC breaks.

I hope it is clear what I mean - Sorry for my poor English grammar.