From aab0953e3118c687e7b22c1da065ca0ad0e3c5ec Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 15 Jun 2017 00:55:50 +0200 Subject: [PATCH] Fix deprecations: remove the old std.string.removechars --- source/dyaml/constructor.d | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/dyaml/constructor.d b/source/dyaml/constructor.d index 301c665..51fa15c 100644 --- a/source/dyaml/constructor.d +++ b/source/dyaml/constructor.d @@ -540,21 +540,21 @@ unittest /// Construct a binary (base64) _node. ubyte[] constructBinary(ref Node node) { + import std.ascii : newline; + import std.array : array; + string value = node.as!string; // For an unknown reason, this must be nested to work (compiler bug?). try { - try{return Base64.decode(value.removechars("\n"));} - catch(Exception e) - { - throw new Exception("Unable to decode base64 value: " ~ e.msg); - } + return Base64.decode(value.representation.filter!(c => !newline.canFind(c)).array); } - catch(UTFException e) + catch(Base64Exception e) { throw new Exception("Unable to decode base64 value: " ~ e.msg); } } + unittest { ubyte[] test = cast(ubyte[])"The Answer: 42"; @@ -564,6 +564,7 @@ unittest auto node = Node(input); auto value = constructBinary(node); assert(value == test); + assert(value == [84, 104, 101, 32, 65, 110, 115, 119, 101, 114, 58, 32, 52, 50]); } /// Construct a timestamp (SysTime) _node.