From c39ffa4dd1e3d3cc077dbc27eaf5488b003e0b84 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 29 Apr 2020 12:24:45 +0100 Subject: [PATCH] add some utf8 getbytes help functions --- OpenSim/Framework/LLSDxmlEncode.cs | 6 ++++++ OpenSim/Framework/Util.cs | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/OpenSim/Framework/LLSDxmlEncode.cs b/OpenSim/Framework/LLSDxmlEncode.cs index a3e7777c87..b84a16505a 100644 --- a/OpenSim/Framework/LLSDxmlEncode.cs +++ b/OpenSim/Framework/LLSDxmlEncode.cs @@ -72,6 +72,12 @@ namespace OpenSim.Framework return sb.ToString(); } + public static byte[] EndToNBBytes(StringBuilder sb) + { + sb.Append(""); + return Util.UTF8NBGetbytes(sb.ToString()); + } + // map == a list of key value pairs public static void AddMap(StringBuilder sb) { diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 1279daf336..e09d64fb62 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -247,6 +247,18 @@ namespace OpenSim.Framework public static Encoding UTF8 = Encoding.UTF8; public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static byte[] UTF8Getbytes(string s) + { + return UTF8.GetBytes(s); + } + + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static byte[] UTF8NBGetbytes(string s) + { + return UTF8NoBomEncoding.GetBytes(s); + } + /// /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) ///