string types: const(char)[] and cstring

Marcin Kuszczak aarti at interia.pl
Tue May 29 14:29:17 PDT 2007


Regan Heath wrote:

> Marcin Kuszczak Wrote:
>> Regan Heath wrote:
>> 
>> > The default language/library support can reverse utf8 and 16 but it's
>> > not ideal, eg.  convert to utf32, reverse, convert back. ;)
>> > 
>> > Regan
>> 
>> I am not sure what do you mean with this sentence...
>> 
>> dstring implementation doesn't do things according to your description,
>> so it's definitely not a case here...
> 
> I'm lost, what is "dstring"?
> 
> All I meant was that using std.utf you can say:
> 
> char[] text = "<characters which take more than 1 char to represent>";
> 
> text = toUTF8(toUTF32(text).reverse);
> 
> and the result will be a correctly reversed UTF8 string.  Or am I missing
> something?
> 
> Regan Heath

dstring is implementation of string struct by Chris Miller which takes care
about slicing utf8 sequences and is compatible with char[], wchar[] and
dchar[]. I mentioned it because I think that it's better when foreach know
nothing about slicing utf8 sequence (opposite to way it is implemented
currently). It should be responsibility of string class (like e.g. dstring)
with proper opApply method. Because my previous e-mail was in context of
dstring, I haven't understood what did you mean... 'reverse' and 'sort'
could be also implemented in such class in a way which will cope properly
with utf8 sequences...

http://www.digitalmars.com/d/archives/digitalmars/D/announce/New_string_implementation_dstring_1.0_4886.html
http://www.dprogramming.com/dstring.php


-- 
Regards
Marcin Kuszczak (Aarti_pl)
-------------------------------------
Ask me why I believe in Jesus - http://zapytaj.dlajezusa.pl (en/pl)
Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/
-------------------------------------




More information about the Digitalmars-d-announce mailing list