Allen
Allen

Reputation: 3771

NSStrings' not equal even though characters are the same

I'm retrieving a string from an NSData object dataOut (coming from a CBCharacteristic), and defining a testString as well which is defined as the same value as shown below: enter image description here

The problem is when I try to compare the two, I get that the two strings are not equal, even though the debugger shows otherwise:

enter image description here

Here is the comparison:

enter image description here

The log keeps logging "Strings are not equal!"

What am I doing wrong? Is the encoding incorrect, even though the strings are the same?

Upvotes: 1

Views: 123

Answers (1)

Bryan Chen
Bryan Chen

Reputation: 46598

You will see them are different when you convert them to NSData and print out the data.

What you see is not always what you get especially with Unicode characters. There maybe invisible characters or some characters that looks similar.

Upvotes: 3

Related Questions