Better warning for smart quotes in C code

Originator:sdfisher
Number:rdar://11725328 Date Originated:21-Jun-2012 11:24 PM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Feature Request Reproducible:Not Applicable
 
21-Jun-2012 11:24 PM Steven Fisher:
Please add a better warning when a smart quote is encountered in Objective-C source. This can happen when copy-pasting code from blogs.

Rationale:

Smart quotes and straight quotes are fairly similar on screen, and can be hard to pick out. However, using smart quotes gives you a strange error message, seemingly unrelated to the smart quote.

Example:

        NSDateFormatter *UTCFormatter = [[NSDateFormatter alloc] init];
        UTCFormatter.timeZone = [NSTimeZone timeZoneWithName:@“UTC”];

I get:

        Unexpected @ in program.

I'd like:

        Found a string using smart quotes: @“UTC”.
        Fix to @"UTC"?

Comments

Added comment about C string to the radar

As follows:

Note that in pure C code, I get a different error. This one is a little better:

char foo[] = “foo”;

I get:

Expected expression.

Would like:

Found smart quotes: “foo”
Fix to "foo"?

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!