digitalmars.D.learn - wstring double quotes to string double quotes
- Joel (11/11) Apr 19 2018 I have a program that uses string double quotes, but copies from
- Adam D. Ruppe (6/9) Apr 19 2018 quotes are quotes, you don't need to convert to wstring here.
- Joel (2/11) Apr 19 2018 That worked! Thanks Adam.
- Jonathan M Davis (8/23) Apr 19 2018 Given that these functions really shouldn't be throw RangeErrors, please
- Joel (2/17) Apr 20 2018 Done.
- Jonathan M Davis (3/25) Apr 20 2018 Thanks!
- ag0aep6g (6/9) Apr 20 2018 [...]
I have a program that uses string double quotes, but copies from wstring double quotes. The wstring double quotes are in string type (sourceTxt is a string with wstring double quotes). The following code crashes with an array.d(2211): Range violation error: import std.conv : to; import std.string : replace; auto sourceTxtW = sourceTxt.to!wstring; sourceTxtW.replace("”", `"`); auto sourceTxtR = sourceTxtW.to!string; sourceLines = sourceTxtR.split("\n");
Apr 19 2018
On Thursday, 19 April 2018 at 21:53:52 UTC, Joel wrote:I have a program that uses string double quotes, but copies from wstring double quotes. The wstring double quotes are in string type (sourceTxt is a string with wstring double quotes).quotes are quotes, you don't need to convert to wstring here. I really don't think it should be throwing that error regardless... but you also should be able to just do string[] sourceLines = sourceTxt.replace("”", `"`).split("\n"); and skip the wstring part entirely.
Apr 19 2018
On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe wrote:On Thursday, 19 April 2018 at 21:53:52 UTC, Joel wrote:That worked! Thanks Adam.I have a program that uses string double quotes, but copies from wstring double quotes. The wstring double quotes are in string type (sourceTxt is a string with wstring double quotes).quotes are quotes, you don't need to convert to wstring here. I really don't think it should be throwing that error regardless... but you also should be able to just do string[] sourceLines = sourceTxt.replace("”", `"`).split("\n"); and skip the wstring part entirely.
Apr 19 2018
On Thursday, April 19, 2018 23:24:05 Joel via Digitalmars-d-learn wrote:On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe wrote:Given that these functions really shouldn't be throw RangeErrors, please create a bug report with example code that can someone can just run to reproduce the issue (your example isn't runnable as-is). That way, the bug can be fixed. Otherwise, it's probably just going to be lost, and someone else may hit it in the future. Thanks. https://issues.dlang.org - Jonathan M DavisOn Thursday, 19 April 2018 at 21:53:52 UTC, Joel wrote:That worked! Thanks Adam.I have a program that uses string double quotes, but copies from wstring double quotes. The wstring double quotes are in string type (sourceTxt is a string with wstring double quotes).quotes are quotes, you don't need to convert to wstring here. I really don't think it should be throwing that error regardless... but you also should be able to just do string[] sourceLines = sourceTxt.replace("”", `"`).split("\n"); and skip the wstring part entirely.
Apr 19 2018
On Friday, 20 April 2018 at 02:46:14 UTC, Jonathan M Davis wrote:On Thursday, April 19, 2018 23:24:05 Joel via Digitalmars-d-learn wrote:Done.On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe wrote:Given that these functions really shouldn't be throw RangeErrors, please create a bug report with example code that can someone can just run to reproduce the issue (your example isn't runnable as-is). That way, the bug can be fixed. Otherwise, it's probably just going to be lost, and someone else may hit it in the future. Thanks. https://issues.dlang.org - Jonathan M Davis[...]That worked! Thanks Adam.
Apr 20 2018
On Friday, April 20, 2018 07:45:14 Joel via Digitalmars-d-learn wrote:On Friday, 20 April 2018 at 02:46:14 UTC, Jonathan M Davis wrote:Thanks! - Jonathan M DavisOn Thursday, April 19, 2018 23:24:05 Joel via Digitalmars-d-learn wrote:Done.On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe wrote:Given that these functions really shouldn't be throw RangeErrors, please create a bug report with example code that can someone can just run to reproduce the issue (your example isn't runnable as-is). That way, the bug can be fixed. Otherwise, it's probably just going to be lost, and someone else may hit it in the future. Thanks. https://issues.dlang.org - Jonathan M Davis[...]That worked! Thanks Adam.
Apr 20 2018
On 04/20/2018 09:45 AM, Joel wrote:On Friday, 20 April 2018 at 02:46:14 UTC, Jonathan M Davis wrote:[...][...]please create a bug reportDone.For reference, that was <https://issues.dlang.org/show_bug.cgi?id=18783>. But someone else was faster and filed <https://issues.dlang.org/show_bug.cgi?id=18781> without giving notice here.
Apr 20 2018