Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 27, 2004 toString() for wchar* | ||||
---|---|---|---|---|
| ||||
May I suggest adding the following functions to Phobos? I'm using them to convert strings from the Unicode versions of the Win32 API.
int strlen(wchar* s)
{
int len = 0;
wchar *c = &s[0];
while (*c++) ++len;
return len;
}
wchar[] toString(wchar* s)
{
return s ? s[0 .. strlen(s)] : cast(wchar[])null;
}
This functions were converted from their "char" equivalents in std.string.
Thanks.
--
Julio César Carrascal Urquijo
|
April 27, 2004 Re: toString() for wchar* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | > int strlen(wchar* s)
> {
> int len = 0;
> wchar *c = &s[0];
> while (*c++) ++len;
> return len;
> }
What's wrong with wcslen?
Or, if you want an overload,
int strlen(wchar *s)
{
return wcslen(s);
}
?
|
April 28, 2004 Re: toString() for wchar* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | Matthew wrote: > >What's wrong with wcslen? > > Obviously wcslen is not obvious <g> -- -Anderson: http://badmama.com.au/~anderson/ |
April 28, 2004 Re: toString() for wchar* | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | Matthew wrote: > What's wrong with wcslen? > > Or, if you want an overload, > > int strlen(wchar *s) > { > return wcslen(s); > } > > ? > Didn't knew it existed! Well I just really need the toString for wchars: wchar[] toString(wchar* s) { return s ? s[0 .. wcslen(s)] : cast(wchar[])null; } -- Julio César Carrascal Urquijo |
Copyright © 1999-2021 by the D Language Foundation