From cd6b510cbd97c350f0a23ad990885f0eb3645507 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Dec 2016 16:05:57 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/Ext.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9c9fdf8c..62045814 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -964,6 +964,20 @@ namespace WebSocketSharp return true; } + internal static bool TryGetUTF8DecodedString (this byte[] bytes, out string s) + { + s = null; + + try { + s = Encoding.UTF8.GetString (bytes); + } + catch { + return false; + } + + return true; + } + internal static bool TryGetUTF8EncodedBytes (this string s, out byte[] bytes) { bytes = null;