Re: mutable string

2016-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 10, 2016 23:38:26 ag0aep6g via Digitalmars-d-learn wrote: > On 07/10/2016 11:26 PM, Adam Sansier wrote: > > For example, I'm trying to compare a wchar buffer with a wstring using > > slices: > > > > x[0..$] == y[0..$] > > > > It fails. I think because x has length 1024. If do > > >

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 11:38 PM, Adam Sansier wrote: Using this code import core.stdc.wchar_; // For wcslen. Hint: D has special syntax for importing only specific parts of a module: import core.std.wchar_: wcslen; wstring toWstring(wchar[] value) { return value ? cast(wstring)

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 11:26 PM, Adam Sansier wrote: For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since it was generated

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 21:26:29 UTC, Adam Sansier wrote: For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 11:17 PM, Adam Sansier wrote: The problem is things like https://msdn.microsoft.com/en-us/library/windows/desktop/ms724902(v=vs.85).aspx require data buffers to be used. I can't just plug in a wstring to it, can I? You can't. `First-chance exception:

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since it was generated from a buffer and the length wasn't set

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 20:31:34 UTC, Lodovico Giaretta wrote: On Sunday, 10 July 2016 at 19:50:28 UTC, Adam Sansier wrote: On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 10:31 PM, Lodovico Giaretta wrote: That said, if you want char[] -> string or wchar[] -> wstring you can use assumeUnique, which casts a mutable array to an immutable one. After having ensured that the array is actually unique. That is, there must not be any other references to

Re: mutable string

2016-07-10 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:50:28 UTC, Adam Sansier wrote: On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than

Re: mutable string

2016-07-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:50:28 UTC, Adam Sansier wrote: But I need to compare the results, case insensitive, to a string(since that is what D uses). It's being a real pain in the butt to deal with the mixture. Are your strings literals or generated somewhere else? You can stick a w at

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? What string functions in particular? If

Re: mutable string

2016-07-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? What string functions in particular? If they are written correctly, it should just work mutable

mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? I'm working with win32 and have to use char*'s. This requires a lot of in place case conversions and comparisons and such. I want to avoid the gc too. I could use