diff --git a/KaitaiStream.cs b/KaitaiStream.cs index a3a80d1..626b485 100644 --- a/KaitaiStream.cs +++ b/KaitaiStream.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; +using System.Globalization; namespace Kaitai { @@ -678,6 +679,22 @@ namespace Kaitai } } + /// + /// Reverses the string, Unicode-aware. + /// + /// taken from here + public static string StringReverse(string s) + { + TextElementEnumerator enumerator = StringInfo.GetTextElementEnumerator(s); + + List elements = new List(); + while (enumerator.MoveNext()) + elements.Add(enumerator.GetTextElement()); + + elements.Reverse(); + return string.Concat(elements); + } + #endregion } }