Friday 15 April 2011

ios - Detect the presence of nonbreaking space in NSString? -


I am trying to create an NSCharacterSet, to test that I do not have a character or a white spot. This character set:

  [NSCharacterSet whitespaceAndNewlineCharacterSet]   

does not contain non-breaking spaces, so I can create my own white space character set I am trying.

  myWhiteSpaceCharacterSet = [NSCharacterSet EligibilitySetWithSlashSign: @ "one \ n \ r \ t"];   

The first letter in my character set is just the space created with the space bar. The second letter will have a place on your browser, although it appears in the form of a dot in the encode, which represents a non-breaking space. I created it by pressing the option key on my Mac and then hit the space bar.

I tried this to test for membership:

  NSString * nonBreakingSpace = @ "one"; Four non-breaking spacescribe = [non-baking spaces characterizedx: 0]; If ([myWhiteSpaceCharacterSet Character Member: Non-breaking Specure]) {NSLog (@ "YES"); } And {nslog (@ "no"); }   

The NSString nonBreakingSpace was created with the Character option- spacebar, but still prints this code.

Any thoughts that I am doing wrong? Or does anyone know about the current character set, which includes all possible types of whitespace? I'm sure I'm missing something ...

Thank you!

instead of char use unichar This is the return type of characterAtIndex: and the non-breaking space character is not fit in a byte, so when it is inserted inhibitly on char Is reduced to

No comments:

Post a Comment