digitalmars.D.learn - wchar* to char[]
- Heinz <malagana15 yahoo.es> Feb 06 2008
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Feb 06 2008
- Sergey Gromov <snake.scaly gmail.com> Feb 06 2008
- doob <doobnet gmail.com> Feb 07 2008
- Sergey Gromov <snake.scaly gmail.com> Feb 07 2008
- doob <doobnet gmail.com> Feb 08 2008
Hi, Is there a way to convert a wchar* variable to char[]? I'm trying to use the Win32 API LoadStringW, wich takes a parameter a wchar*. Thanx.
Feb 06 2008
"Heinz" <malagana15 yahoo.es> wrote in message news:foe0pj$mct$1 digitalmars.com...Hi, Is there a way to convert a wchar* variable to char[]? I'm trying to use the Win32 API LoadStringW, wich takes a parameter a wchar*.
So, you have a function that takes a wchar*, and you have a wchar*. .. I'm not seeing how char[] comes into this at all.
Feb 06 2008
Heinz <malagana15 yahoo.es> wrote:Is there a way to convert a wchar* variable to char[]? I'm trying to use the Win32 API LoadStringW, wich takes a parameter a wchar*.
Assuming that `src' is a wchar* string, in Phobos it's like this: import std.utf; extern(C) uint wcslen(in wchar* str); // a C runtime library function char[] str = toUTF8(src[0..wcslen(src)]); In Tango, this would be: import tango.text.convert.Utf; import tango.text.Util; auto len = indexOf(src, '\u0000', uint.max); char[] str = toString(src[0..len]); -- SnakE
Feb 06 2008
Sergey Gromov wrote:Heinz <malagana15 yahoo.es> wrote:Is there a way to convert a wchar* variable to char[]? I'm trying to use the Win32 API LoadStringW, wich takes a parameter a wchar*.
Assuming that `src' is a wchar* string, in Phobos it's like this: import std.utf; extern(C) uint wcslen(in wchar* str); // a C runtime library function char[] str = toUTF8(src[0..wcslen(src)]); In Tango, this would be: import tango.text.convert.Utf; import tango.text.Util; auto len = indexOf(src, '\u0000', uint.max); char[] str = toString(src[0..len]);
I would do like this: Phobos: import std.string; import std.utf; // alias for char[] (D 1.x) string str = toUTF8(toString(src)); Tango: import tango.stdc.stringz; import tango.text.convert.Utf; char[] str = toString(fromString16z(str));
Feb 07 2008
doob <doobnet gmail.com> wrote:Sergey Gromov wrote:Heinz <malagana15 yahoo.es> wrote:Is there a way to convert a wchar* variable to char[]? I'm trying to use the Win32 API LoadStringW, wich takes a parameter a wchar*.
Assuming that `src' is a wchar* string, in Phobos it's like this: import std.utf; extern(C) uint wcslen(in wchar* str); // a C runtime library function char[] str = toUTF8(src[0..wcslen(src)]);
I would do like this: Phobos: import std.string; import std.utf; // alias for char[] (D 1.x) string str = toUTF8(toString(src));
In Phobos, there is no function "std.string.toString(wchar*)". -- SnakE
Feb 07 2008
Sergey Gromov wrote:doob <doobnet gmail.com> wrote:Sergey Gromov wrote:Heinz <malagana15 yahoo.es> wrote:Is there a way to convert a wchar* variable to char[]? I'm trying to use the Win32 API LoadStringW, wich takes a parameter a wchar*.
import std.utf; extern(C) uint wcslen(in wchar* str); // a C runtime library function char[] str = toUTF8(src[0..wcslen(src)]);
Phobos: import std.string; import std.utf; // alias for char[] (D 1.x) string str = toUTF8(toString(src));
In Phobos, there is no function "std.string.toString(wchar*)".
Feb 08 2008









"Jarrett Billingsley" <kb3ctd2 yahoo.com> 