From e58b092fe11620e84e1e296912d560503ab3a7cc Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Wed, 30 Jul 2014 18:23:40 +0200 Subject: [PATCH] Removed an unsafe cast. --- source/dyaml/reader.d | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/dyaml/reader.d b/source/dyaml/reader.d index 3aa7611..fec8c7d 100644 --- a/source/dyaml/reader.d +++ b/source/dyaml/reader.d @@ -740,7 +740,7 @@ auto toUTF8(ubyte[] input, const UTFEncoding encoding) @safe pure nothrow // result = A Result struct to put encoded result and any error messages to. // // On error, result.errorMessage will be set. - static void encode(C)(C[] input, ref Result result) @trusted pure nothrow + static void encode(C)(C[] input, ref Result result) @safe pure nothrow { try { @@ -772,9 +772,10 @@ auto toUTF8(ubyte[] input, const UTFEncoding encoding) @safe pure nothrow } result.utf8 = utf8[0 .. length]; } + // Unfortunately we can't do UTF-16 in place so we just use std.conv.to else { - result.utf8 = cast(char[])input.to!string; + result.utf8 = input.to!(char[]); } } catch(ConvException e) { result.errorMessage = e.msg; }