Re: How to ensure string compatibility In D?

2019-01-23 Thread FrankLike via Digitalmars-d-learn
On Wednesday, 23 January 2019 at 14:12:09 UTC, Jonathan M Davis wrote: On Wednesday, January 23, 2019 5:42:55 AM MST FrankLike via std.conv.to will allow you to convert between string and wstring, but for calling C functions, you still need the strings to be zero-terminated unless the functio

Re: How to ensure string compatibility In D?

2019-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 23, 2019 5:42:55 AM MST FrankLike via Digitalmars-d- learn wrote: > On Wednesday, 23 January 2019 at 10:44:51 UTC, Jonathan M Davis > > wrote: > > On Tuesday, January 22, 2019 2:49:00 PM MST bauss via > > Digitalmars-d-learn wrote: > > > > toUTFz is the generic solution. toStr

Re: How to ensure string compatibility In D?

2019-01-23 Thread FrankLike via Digitalmars-d-learn
On Wednesday, 23 January 2019 at 10:44:51 UTC, Jonathan M Davis wrote: On Tuesday, January 22, 2019 2:49:00 PM MST bauss via Digitalmars-d-learn wrote: toUTFz is the generic solution. toStringz exists specifically Error: template std.utf.toUTFz cannot deduce function from argument types !()

Re: How to ensure string compatibility In D?

2019-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 22, 2019 2:49:00 PM MST bauss via Digitalmars-d-learn wrote: > On Tuesday, 22 January 2019 at 19:14:43 UTC, Jonathan M Davis > > wrote: > > On Tuesday, January 22, 2019 12:05:32 PM MST Stefan Koch via > > > > Digitalmars-d- learn wrote: > >> On Tuesday, 22 January 2019 at 16:47

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 21:49:00 UTC, bauss wrote: On Tuesday, 22 January 2019 at 19:14:43 UTC, Jonathan M Davis Is there a reason we cannot implement toStringz like: immutable(TChar)* toStringz(TChar = char)(scope const(TChar)[] s) @trusted pure nothrow; // Couldn't find a way to ge

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 21:49:00 UTC, bauss wrote: On Tuesday, 22 January 2019 at 19:14:43 UTC, Jonathan M Davis Is there a reason we cannot implement toStringz like: immutable(TChar)* toStringz(TChar = char)(scope const(TChar)[] s) @trusted pure nothrow; // Couldn't find a way to ge

Re: How to ensure string compatibility In D?

2019-01-22 Thread bauss via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 19:14:43 UTC, Jonathan M Davis wrote: On Tuesday, January 22, 2019 12:05:32 PM MST Stefan Koch via Digitalmars-d- learn wrote: On Tuesday, 22 January 2019 at 16:47:45 UTC, FrankLike wrote: > On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe > > wrote: >> U

Re: How to ensure string compatibility In D?

2019-01-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 22, 2019 12:05:32 PM MST Stefan Koch via Digitalmars-d- learn wrote: > On Tuesday, 22 January 2019 at 16:47:45 UTC, FrankLike wrote: > > On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe > > > > wrote: > >> Use "mystring"w, notice the w after the closing quote. > > > >

Re: How to ensure string compatibility In D?

2019-01-22 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:47:45 UTC, FrankLike wrote: On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe wrote: Use "mystring"w, notice the w after the closing quote. Or toStringz is not work like c_str() in C++? stringz creates a char* but you need a wchar*

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe wrote: Use "mystring"w, notice the w after the closing quote. Or toStringz is not work like c_str() in C++?

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe wrote: Use "mystring"w, notice the w after the closing quote. "GetDriveType" Function is auto work by "_T" in C++,but how to do in D?

Re: How to ensure string compatibility In D?

2019-01-22 Thread Adam D. Ruppe via Digitalmars-d-learn
Use "mystring"w, notice the w after the closing quote.

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 16:13:57 UTC, FrankLike wrote: On Tuesday, 22 January 2019 at 14:07:48 UTC, Olivier Pisano wrote: Some error is in "core.sys.windows.windows"? Thank you.

Re: How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 14:07:48 UTC, Olivier Pisano wrote: On Tuesday, 22 January 2019 at 13:55:30 UTC, FrankLike wrote: In D, there is only Unicode. The language doesn't manipulate strings encoded in Windows local code-pages. For example: std::wstring strTest(_T("d://")); UINT nR

Re: How to ensure string compatibility In D?

2019-01-22 Thread Olivier Pisano via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 13:55:30 UTC, FrankLike wrote: Hi,everyone, In C++, _T can guarantee that when converting from ascii encoding type to unicode encoding type, the program does not need to be modified. What do I need to do in D? Thanks. Hi, _T is not relevant to C++, but to W

How to ensure string compatibility In D?

2019-01-22 Thread FrankLike via Digitalmars-d-learn
Hi,everyone, In C++, _T can guarantee that when converting from ascii encoding type to unicode encoding type, the program does not need to be modified. What do I need to do in D? Thanks.