Implement StringReverse method
This commit is contained in:
parent
152ddd9dd8
commit
d62f34fcad
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Kaitai
|
namespace Kaitai
|
||||||
{
|
{
|
||||||
|
@ -678,6 +679,22 @@ namespace Kaitai
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reverses the string, Unicode-aware.
|
||||||
|
/// </summary>
|
||||||
|
/// <a href="https://stackoverflow.com/a/15029493">taken from here</a>
|
||||||
|
public static string StringReverse(string s)
|
||||||
|
{
|
||||||
|
TextElementEnumerator enumerator = StringInfo.GetTextElementEnumerator(s);
|
||||||
|
|
||||||
|
List<string> elements = new List<string>();
|
||||||
|
while (enumerator.MoveNext())
|
||||||
|
elements.Add(enumerator.GetTextElement());
|
||||||
|
|
||||||
|
elements.Reverse();
|
||||||
|
return string.Concat(elements);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue