I’m trying to create a JQuery function that will test a string for the presence of a specific UTF-8 Character.
In this case the character is U+00AD (Soft Hyphen).
Here is one variation of the function I’ve tried, but just can’t find a working solution.
var index = obj.value.indexOf($('­').text());
var isMatch = index >= 0;
if (isMatch) {
//Do match work
}
Can anyone suggest a fix; or something else; I can use to accomplish this?
That’s a unicode character; UTF8 is just an encoding.
You can put the character directly in the string. However, since it’s invisible, it would be more readable to use a Javascript escape sequence:
"\u00AD"