No. I think the implementor of Factor's unicode support originally did that but it turns out to not be useful:
* it blows up memory usage for ASCII and BMP (4 bytes per codepoint versus 1~3)
* this also has impact on CPU caches, lowering the average amount of data you can fit in your cache and work on
* it requires a complete conversion of incoming ascii and utf8 data (which only get more and more common as time goes on) rather than just a validation
* and because Unicode itself is variable-length (combining codepoints) it's not actually helpful when you're trying to properly manipulate unicode data
The only "advantage" of representing strings as codepoint arrays is that you get O(1) access to codepoints which is a terrible idea you should not encourage.
UTF-32 internal encoding makes some manipulations very slightly easier, but not enough to matter in the long run, and it encourages bad habits. If you don't need the O(1) access thing for backwards compatibility reasons, don't bother.
I have written my own unicode library, normalizing strings as UTF-32 is MUCH MUCH MUCH easier than trying to do the same in UTF-8 or UTF-16.
not to mention casefolding, and it also allows you to design better interfaces, so that the actual algorithm only needs to be implemented once.
> it blows up memory usage for ASCII and BMP (4 bytes per codepoint versus 1~3)
[0] not that that's always the case, the navajo alphabet can have both ogonek and acute on the same latin base character
Python 3.3+, I believe, looks at the string and chooses ASCII/UCS-2/UCS-4 based on the character that takes the highest amount of bytes [1]. Elixir uses UTF-8 for strings (but you can get the codepoints easily), whereas Erlang uses the list of unicode ints style.
[1] https://www.b-list.org/weblog/2017/sep/05/how-python-does-un...
If by "arrays of codepoints" you mean "each element of the array is a single codepoint", then you get O(1) indexing regarding codepoints, but may use up to 4x the memory as the variable-length encoding.
Seriously, how many strings have you ever ran across that are more than 1kb?
how many strings have you ran across that are more than 256 codepoints?
I see strings larger than that all the time, and care about using low RSS. YMMV.
the packet's themselves are only 1.5kb.
Luckily not. If you absolutely must deal with legacy encodings, feed them through a conversion pass beforehand.