digitalmars.D.learn - Unicode exception raise when replacing underscore with space
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (9/9) Jan 13 2015 I get
- Daniel =?UTF-8?B?S296w6Fr?= via Digitalmars-d-learn (4/19) Jan 13 2015 V Tue, 13 Jan 2015 12:32:15 +0000
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (4/6) Jan 13 2015 Thanks! What about adding See alsos in the docs that relate these
- Daniel Kozak (9/16) Jan 13 2015 I am not sure, it doesn`t exactly do the same. And to be fair
I get core.exception.UnicodeException src/rt/util/utf.d(290): in a call to std.string.tr(x, `_`, ` `) for a badly encode string x. Is it really needed to do auto-decoding here? Isn't the encoding of underscore and space uniquely one by byte in UTF-8? What do I need to do/add to avoid auto-decoding here?
Jan 13 2015
V Tue, 13 Jan 2015 12:32:15 +0000 "Nordlöw" via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> napsáno:I get core.exception.UnicodeException src/rt/util/utf.d(290): in a call to std.string.tr(x, `_`, ` `) for a badly encode string x. Is it really needed to do auto-decoding here? Isn't the encoding of underscore and space uniquely one by byte in UTF-8? What do I need to do/add to avoid auto-decoding here?std.array.replace(x, `_`, ` `);
Jan 13 2015
On Tuesday, 13 January 2015 at 13:01:56 UTC, Daniel Kozák via Digitalmars-d-learn wrote:Thanks! What about adding See alsos in the docs that relate these two with respect to auto-decoding?What do I need to do/add to avoid auto-decoding here?std.array.replace(x, `_`, ` `);
Jan 13 2015
On Tuesday, 13 January 2015 at 20:30:16 UTC, Nordlöw wrote:On Tuesday, 13 January 2015 at 13:01:56 UTC, Daniel Kozák via Digitalmars-d-learn wrote:I am not sure, it doesn`t exactly do the same. And to be fair std.array.replace use internaly std.algorithm.find which use in some scenario auto-decoding. So to be sure no autodecoding occured you must used something like that: string x = "some_text"; auto res = std.array.replace(cast(byte[])x, [byte('_')], [byte(' ')]); writeln(cast(string)res);Thanks! What about adding See alsos in the docs that relate these two with respect to auto-decoding?What do I need to do/add to avoid auto-decoding here?std.array.replace(x, `_`, ` `);
Jan 13 2015