Unicode exception raise when replacing underscore with space

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 13 13:26:02 PST 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:
>>> What do I need to do/add to avoid auto-decoding here?
>>
>> std.array.replace(x, `_`, ` `);
>
> Thanks! What about adding See alsos in the docs that relate 
> these two with respect to auto-decoding?

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);


More information about the Digitalmars-d-learn mailing list