I have a CharSequence
which contains two ˚
(degree) symbol inside it.
I have written an if
statement which detects what's inside this CharSequence
like this:
CharSequence name = "27°46'29.6"N 77°19'05.9"E";
if (name.toString().contains("˚") {
Log.d("log", "˚ detected");
} else {
Log.d("log", "˚ not detected");
}
The problem is that here ˚ detected
is supposed to be printed out by the log statements, but what is getting printed out is ˚ not detected
.
Why the ˚
is not getting detected?
You're checking 2 different characters, code point 176 vs 730
if (name.toString().contains("°")) {