D - converting wide to c
- Lewis (29/29) Dec 18 2003 ok i looked thru the string functions an found toCharz() to convert a wi...
- Walter (6/30) Dec 18 2003 Check out std.utf.toUTF8(wchar[]).
- Lewis (2/4) Dec 18 2003 thanks walter, your the man!
- Lewis (5/5) Dec 18 2003 wow i can see a bad habit starting, but how is it possible to have 3 fun...
- J C Calvarese (14/21) Dec 18 2003 It's okay. They have 3 sets different argument litss: (char[]),
- Lewis (3/36) Dec 18 2003 wow, now these are features i like! Thanks for the help guys.
- Walter (6/11) Dec 18 2003 It picks one based on the type of the argument you supply to it.
ok i looked thru the string functions an found toCharz() to convert a wide string to a null terminated string, but when i tried to use it it told me it wasnt appreciated :( (depreciated lol) so then i of course i tried to write my own an failed miserably... would anyone care to give me a hint on how to make this work? or is there another function i can use somewhere... thanks //Convert a wide string to a 'c' string char[] WideToAscii(wchar[] WideArr) { int i = 0; int Count = 0; char[] CharArr; i.init; Count.init; if ( WideArr.length > 0 ) { CharArr.length = (WideArr.length / 2) + 1; while ( i < WideArr.length ) { CharArr[Count] = (char) WideArr[i]; i += 2; Count += 1; } } CharArr[CharArr.length - 1] = (char)r"0"; return CharArr; } :) yes i have a long way to go lol
Dec 18 2003
Check out std.utf.toUTF8(wchar[]). "Lewis" <dethbomb hotmail.com> wrote in message news:brtfti$20j8$1 digitaldaemon.com...ok i looked thru the string functions an found toCharz() to convert a wide string to a null terminated string, but when i tried to use it it told meitwasnt appreciated :( (depreciated lol) so then i of course i tried towrite myown an failed miserably... would anyone care to give me a hint on how tomakethis work? or is there another function i can use somewhere... thanks //Convert a wide string to a 'c' string char[] WideToAscii(wchar[] WideArr) { int i = 0; int Count = 0; char[] CharArr; i.init; Count.init; if ( WideArr.length > 0 ) { CharArr.length = (WideArr.length / 2) + 1; while ( i < WideArr.length ) { CharArr[Count] = (char) WideArr[i]; i += 2; Count += 1; } } CharArr[CharArr.length - 1] = (char)r"0"; return CharArr; } :) yes i have a long way to go lol
Dec 18 2003
Walter wrote:Check out std.utf.toUTF8(wchar[]).thanks walter, your the man!
Dec 18 2003
wow i can see a bad habit starting, but how is it possible to have 3 functions with the same name? how do i specify which one to use (it just wants to use the first one and i get a type mismatch compile error) Do i have to comment out the ones that i dont want to use? sorry if im being a pain
Dec 18 2003
Lewis wrote:wow i can see a bad habit starting, but how is it possible to have 3 functions with the same name?It's okay. They have 3 sets different argument litss: (char[]), (wchar[]), (dchar[]).how do i specify which one to use (it just wants to use the first one and i get a type mismatch compile error) Do i have to comment out the ones that i dont want to use?No. You shouldn't have to comment out anything in phobos. I'm not sure what the problem is. My blind guess is that you need to use a cast: toUTF8(cast(wchar[]) "your string") or toUTF8(cast(wchar[]) str) (By the way, it does help if you include a snippet of code. Sometimes, the solution is obvious if we see it.)sorry if im being a painDon't worry about it. We've all starting programming in D fairly recently. :) Justin
Dec 18 2003
J C Calvarese wrote:Lewis wrote:Walter wrote:wow i can see a bad habit starting, but how is it possible to have 3 functions with the same name?It's okay. They have 3 sets different argument litss: (char[]), (wchar[]), (dchar[]).how do i specify which one to use (it just wants to use the first one and i get a type mismatch compile error) Do i have to comment out the ones that i dont want to use?No. You shouldn't have to comment out anything in phobos. I'm not sure what the problem is. My blind guess is that you need to use a cast: toUTF8(cast(wchar[]) "your string") or toUTF8(cast(wchar[]) str) (By the way, it does help if you include a snippet of code. Sometimes, the solution is obvious if we see it.)sorry if im being a painDon't worry about it. We've all starting programming in D fairly recently. :) JustinIt picks one based on the type of the argument you supply to it.wow, now these are features i like! Thanks for the help guys.
Dec 18 2003
It picks one based on the type of the argument you supply to it. "Lewis" <dethbomb hotmail.com> wrote in message news:brtv0l$2mvh$1 digitaldaemon.com...wow i can see a bad habit starting, but how is it possible to have 3functionswith the same name? how do i specify which one to use (it just wants touse thefirst one and i get a type mismatch compile error) Do i have to commentout theones that i dont want to use? sorry if im being a pain
Dec 18 2003