From f6457f232133a1d6b8d5446a3dbeb8d6a0dc8791 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Wed, 23 Jul 2014 18:18:21 +0200 Subject: [PATCH] Added a nothrow function to convert dstring to string. --- source/dyaml/scanner.d | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index 3489747..91ab319 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -1654,3 +1654,14 @@ final class Scanner return '\0'; } } + +private: + +/// A nothrow function that converts a dstring to a string. +string utf32To8(dstring str) @safe pure nothrow +{ + try { return str.to!string; } + catch(ConvException e) { assert(false, "Unexpected invalid UTF-32 string"); } + catch(Exception e) { assert(false, "Unexpected exception during UTF-8 encoding"); } +} +