In the following string:
ප්රන
The zero-width character u200D is being used to join two characters. You can check the presence of this character in https://www.babelstone.co.uk/Unicode/whatisit.html
If the character is removed, the other two characters around it aren’t joined and therefore look like this:
ප්රන
However, the same character and another similar character u200C can be used in places where it’s unnecessary, to just increase character count without the characters being visible or doing anything.
How to check if the characters u200C and u200D is doing something (joining two characters around it) or just sitting there doing nothing?
I tried to following code but it does not work:
static void IsNeeded(string input)
{
bool hasZWJ = input.Contains('u200D');
if (hasZWJ)
{
int index = input.IndexOf('u200D');
if (index > 0 && Char.IsHighSurrogate(input[index + 1]))
{
Console.WriteLine($"{input}:The ZWJ character is used to join characters together");
}
else
{
Console.WriteLine($"{input}:The ZWJ character is not needed in the string");
}
}
}
18
The . contains () method whether a string includes a particular character or substring it returns true if the character is included , otherwise the method returns false . there are additional parameters that can modify the comparison rules .
hope it helps you out
itz Kim nahee
🌺🌺🌺
Kim nahee 656 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3