Re: Quotation marks in NSMenu
Re: Quotation marks in NSMenu
- Subject: Re: Quotation marks in NSMenu
- From: Ken Thomases <email@hidden>
- Date: Sat, 6 Mar 2010 03:35:28 -0600
On Mar 6, 2010, at 2:53 AM, Martin Hewitson wrote:
> I guess this is an easy question, but I couldn't find the answer with google (probably due to difficulties in phrasing the question).
>
> If one looks in Xcode under: File->Close File "foo.m"
>
> then one sees 'proper' opening and closing quotation marks. When I put quotation marks in a string in my own menu (setTitle:) then I just get 'normal' quotation marks.
>
> Does anyone know how to achieve the 'proper' quotation marks?
Those are sometimes referred to as typesetter's quotes or smart quotes (although the latter really refers to the software feature which converts straight quotes to typesetter's quotes automatically).
There are a few ways. You can type those characters using the U.S. keyboard layout with Option-[ and Option-Shift-[. If you go this route, you should probably set the file's encoding as UTF-8. Use Xcode's File > Get Info menu item on the file.
Those characters are U+201C and U+201D. You can also put them into a string using the \unnnn escape sequence. So, something like:
[NSString stringWithFormat:@"\u201c%@\u201d", [[NSFileManager defaultManager] displayNameAtPath:somePath]]
will quote the display name of a file. (Always use the display name of file system items for the GUI.)
Neither of the above techniques work with GCC 4.0.x, which is required when building against the 10.4 SDK. If you're using that version of the compiler, you can instead combine NSLocalizedString and friends, the \\Unnnn escape sequence (notice the double backslashes), and the -u option to genstrings. Then, your compiled code will have somewhat odd pure ASCII strings in it, but at runtime they will be looked up in the .strings file, which can return the proper strings with the typesetter's quotes embedded in them.
To get the typesetter's single quotes, the key combinations are Option-] and Option-Shift-]. The Unicode codepoints are U+2018 and U+2019.
Cheers,
Ken
_______________________________________________
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