A small library to help you manipulate strings without paying attention to supplementary characters.
You can visit MSDN for detailed information about supplementary characters and surrogates.
Create new SFString
object by passing your string into a constructor.
string exampleString = @"This 👉 is 🅰 an example string with emojis 👨👩👧👧.";
SFString surrogateFreeString = new SFString(exampleString);
This will create a representation of your string where any surrogate pair will count as one symbol.
After that you can manipulate it just like a string
. Actually for now there are only Substring(int, int)
and Substring(int)
methods.
SFString firstTwoCharacters = surrogateFreeString.Substring(0, 2);
SFString allCharactersAfterFirstTwo = surrogateFreeString.Substring(2);
To get a string
after you finished minupulations you wanted just use ToString()
.
var finalString = firstTwoCharacters.ToString();
This project is licensed under the WTFPL License.