tags:

views:

23

answers:

1
if (myChar == '"') 
if ([myChar compare:@"\""]) 
if ([myChar isEqual:@"\""]) 
if (myChar == @"\"")

None of the comparisons above seem to work. I need to check if myChar, which is taken from an NSString, is a quotation mark.

Any ideas?

A: 

The first one works, actually, if myChar is actually a char. The question is a bit unclear: are you trying to compare to a quote ('"') or a question mark ('?') ?

But yea, the first one works.

Jared P
Doing that will check if `myChar` literally equals `\"`...
Douwe Maan
yea I just double checked and changed my answer -- the first given example should work, no?
Jared P
That does not seem to work for me. The char will be either a letter A - Z or a " mark. I want to check for the " marks and handle them accordingly.
Oh Danny Boy
Is it an NSString or char * string of length 1? or a char (or a unichar)? If it is the former, then the question was not phrased correctly, although I would be happy to respond to that instead.
Jared P
I need to compare unichar to a quotation mark.
Oh Danny Boy
In unicode, there're three double quotation marks. Left-right symmetric one " , the opening quote “ and the closing quote ”. Are you sure you have the symmetric one?
Yuji