objective c - How do I match non-ASCII characters with RegexKitLite? -
I am using RegexKitLite and I am trying to match a pattern.
The following regex patterns do not capture my word in which the N is included with a heading: ñ. Is there a string conversion that I'm missing?
subject string = "defined_anard"; // regexString = @ "^ define _ (. *)"; // This pattern does not match, so I think that adding // / regexString == "^ define _ ([.nn] *); // a range regexString = @" ^ define _ ((?: \ \ W | n) *) with this pattern first tried; // tried the second NSString * Capture = [StringByMatching the subjectString: capture regexString: 1L]; // I look like an encoding problem I == añadir
Either you Going back to the original regex that are saving the source code in that encoding, you can not handle that character (such as ASCII), or using the wrong encoding to read the compiler source files, create such a topic string Try:
topic string = "define_a \ xC3 \ xB1adir";
Or this:
subject string = "define_a \ u00f1adir";
If that works, check the encoding of your source code files and make sure that it expects the compiler to be the same encoding.
Edit: I have never worked with the iPhone Technology Stack, but according to you, the stringWithUTF8String
method should be used, to create NSString, not The literal syntax actually says that you should never use non-ASCII characters in your code (which is nothing, limit
0x00..0x7F
); In this way you do not have to worry about the source file's encoding. It is a good idea to use which language or toolset you are using.
Comments
Post a Comment