Re: Filenames with Umlauts
Re: Filenames with Umlauts
- Subject: Re: Filenames with Umlauts
- From: Chris Hanson <email@hidden>
- Date: Sat, 5 Jul 2003 12:39:46 -0500
On Saturday, July 5, 2003, at 04:28 AM, Gerriet M. Denkmann wrote:
// this works, because my source file is in utf-8 format.
const char bear_utf8[] = "B@r" ; // a German animal
NSString *bear_precomp = [ NSString stringWithUTF8String: bear_utf8 ] ;
NSString *bear_decomp = [ bear_precomp
decomposedStringWithCanonicalMapping ];
// the bear is now called: "Ba 'combining diaresis' r"
NSString *bear_path = [ mainBundle pathForResource: bear_decomp
ofType: nil ] ;
Is there a shorter or better way to get at my bear?
You shouldn't have to do the mapping bit; you should just be able to
use bear_precomp to find your file.
Better would be to use an ASCII constant string for the file name, and
if you need it to be localized use the localization machinery:
NSString *bearPath
= [mainBundle pathForResource:NSLocalizedString(@"Bear", @"name of
Bear file")
ofType:nil];
In your German.lproj/Localizable.strings file, you could then have an
entry
/* name of Bear file */
"Bear" = "B@r";
to get the path to the right localized file. And assuming your
project's development language is set to German, it should even look
for the right localized file ("B@r") when running under a language you
don't support.
You can do this for any string used anywhere for any purpose in your
application.
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Application Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.