Removed an unsafe cast.

This commit is contained in:
Ferdinand Majerech 2014-07-30 18:23:40 +02:00
parent 492e36d28a
commit e58b092fe1

View file

@ -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. // result = A Result struct to put encoded result and any error messages to.
// //
// On error, result.errorMessage will be set. // 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 try
{ {
@ -772,9 +772,10 @@ auto toUTF8(ubyte[] input, const UTFEncoding encoding) @safe pure nothrow
} }
result.utf8 = utf8[0 .. length]; result.utf8 = utf8[0 .. length];
} }
// Unfortunately we can't do UTF-16 in place so we just use std.conv.to
else else
{ {
result.utf8 = cast(char[])input.to!string; result.utf8 = input.to!(char[]);
} }
} }
catch(ConvException e) { result.errorMessage = e.msg; } catch(ConvException e) { result.errorMessage = e.msg; }