To Walter, about char[] initialization by FF
Derek Parnell
derek at nomail.afraid.org
Mon Jul 31 18:51:03 PDT 2006
On Mon, 31 Jul 2006 18:23:19 -0700, Andrew Fedoniouk wrote:
> "Walter Bright" <newshound at digitalmars.com> wrote in message
> news:eam1ec$10e1$1 at digitaldaemon.com...
>> Andrew Fedoniouk wrote:
>>> The problem as I can see is this:
>>> D propose to use transport encoding for manipulation purposes
>>> which is main problem imo here - transport encodings are not
>>> designed for the manipulation - it is extremely difficult to use
>>> them for manipualtion in practice as we may see.
>>
>> I disagree the characterization that it is "extremely difficult" to use
>> for manipulation. foreach's direct support for it, as well as the
>> functions in std.utf, make it straightforward. DMDScript is built around
>> UTF-8, and manipulating multibyte characters in it has not turned out to
>> be a significant problem.
>
> Sorry but strings in DMDScript are quite different in terms of
> 0) there are no such thing as char in JavaScript.
> 1) strings are Strings - not vectors of octets - js::string[] and d::char[]
> are different things.
> 2) are not supposed to be used by any OS API.
> 3) there are 12 or so methods of String class in JS - limited perimeter -
> what model you've choosen to store them is irrelevant -
> in some implementations they represented even by list of fixed runs.
For what its worth, to do *character* manipulation I convert strings to
UTF-32, do my stuff and convert back to the initial format.
char[] somefunc(char[] x)
{
return std.utf.toUTF8( somefunc( std.utf.toUTF32(x) ) );
}
wchar[] somefunc(wchar[] x)
{
return std.utf.toUTF16( somefunc( std.utf.toUTF32(x) ) );
}
dchar[] somefunc(dchar[] x)
{
dchar[] result;
...
return result;
}
This seems to work fast enough for my purposes. DBuild (nee Build) uses
this a lot.
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
1/08/2006 11:45:36 AM
More information about the Digitalmars-d
mailing list