Re: How to detect curly quotes
Re: How to detect curly quotes
- Subject: Re: How to detect curly quotes
- From: Dave DeLong <email@hidden>
- Date: Wed, 01 Apr 2009 18:05:46 -0600
Just to chime in.... The RegexKit linked below is absolutely
FANTASTIC. I use it pretty much any time I need to do beyond-basic
text manipulation. RegexKitLite is some NSString categories, allowing
you to do things like [myString isMatchedByRegex:@"some regex"] and so
on. It's incredibly useful.
Dave
On Mar 31, 2009, at 5:55 PM, John Engelhart wrote:
You can use regular expressions. RegexKitLite @
http://regexkit.sourceforge.net/RegexKitLite/ which you can download
at
http://downloads.sourceforge.net/regexkit/RegexKitLite-2.2.tar.bz2
For example, you can be extremely lazy and do something along the
lines of:
NSStringEncoding fileEncoding;
NSString *fileString = [[NSString stringWithContentsOfFile:@"file.txt"
usedEncoding:&fileEncoding error:NULL]
stringByReplacingOccurrencesOfRegex:@
"[\u201c\u201d]" withString:@"\""];
And violla! This will turn “ (\u201c) and ” (\u201d) in 'file.txt'
into a
plain " (ascii 0x22), the result of which is fileString.
There's other methods available as well if you just need to find the
locations of the curly quotes and what not. Well documented, and the
documentation is available in .docset format so it's integrated and
available inside Xcode, just like all the other documentation.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden