nette / utils

🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
https://doc.nette.org/utils
Other
1.98k stars 147 forks source link

Strings: Add range() function with UTF-8 support. #224

Closed janbarasek closed 4 years ago

janbarasek commented 4 years ago

Added new function range() for safe generating of characters interval.

It can be used in Random helper for support intervals like '0-9a-zA-Zá-ž' (Czech á - ž).

Thanks.

dg commented 4 years ago

Can you add some tests please?

janbarasek commented 4 years ago

@dg Some tests added for clear cases.

I am not sure what is best behavior for input like range('á', 'ž'). We can support all alphabets or most common characters only (stored in array or string)?

JanTvrdik commented 4 years ago

I don't think this is a good idea. Unicode ranges are rarely usable. It's not sorted logically like alphabet where the order is well defined.