On 1/29/17 3:52 AM, Stefan Koch wrote:
On Sunday, 29 January 2017 at 02:46:16 UTC, pineapple wrote:
On Sunday, 29 January 2017 at 02:17:12 UTC, Stefan Koch wrote:
Also my ctfe engine still requires utf8 support, for string-foreach.
[ ... ]
Can you clarify what string-foreach refers to? Surely not `foreach(ch;
some_string){}`, which enumerates code units and not code points?
Yes exactly that. many times in phobos foreach(dchar ch; some_string)
which requires me to encode the utf8 string temporarily into utf32
and then when it is appending to some other string I need to reencode it
into utf8.
Why encode the whole string to utf32? You can lower it to use
std.utf.decode in a loop.
Essentially this:
foreach(dchar ch; some_string){ ... }
Becomes:
import std.utf;
size_t i=0;
while(i<some_string.length){
dchar ch = decode(some_string, i);
...
}
---
Dmitry Olshansky