digitalmars.D.learn - wchar* to char[]
- Heinz (3/3) Feb 06 2008 Hi,
- Jarrett Billingsley (5/8) Feb 06 2008 So, you have a function that takes a wchar*, and you have a wchar*.
- Sergey Gromov (12/13) Feb 06 2008 Assuming that `src' is a wchar* string, in Phobos it's like this:
- doob (11/29) Feb 07 2008 I would do like this:
- Sergey Gromov (4/24) Feb 07 2008 In Phobos, there is no function "std.string.toString(wchar*)".
- doob (2/24) Feb 08 2008 My bad, it was only for char*
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: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));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]);
Feb 07 2008
doob <doobnet gmail.com> wrote:Sergey Gromov wrote:In Phobos, there is no function "std.string.toString(wchar*)". -- SnakEHeinz <malagana15 yahoo.es> wrote:I would do like this: Phobos: import std.string; import std.utf; // alias for char[] (D 1.x) string str = toUTF8(toString(src));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)]);
Feb 07 2008
Sergey Gromov wrote:doob <doobnet gmail.com> wrote:My bad, it was only for char*Sergey Gromov wrote:In Phobos, there is no function "std.string.toString(wchar*)".Heinz <malagana15 yahoo.es> wrote:I would do like this: Phobos: import std.string; import std.utf; // alias for char[] (D 1.x) string str = toUTF8(toString(src));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)]);
Feb 08 2008