Re: Filenames with Umlauts
Re: Filenames with Umlauts
- Subject: Re: Filenames with Umlauts
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sun, 6 Jul 2003 11:25:37 +0200
On Sonntag, Juli 6, 2003, at 03:16 Uhr,
email@hidden wrote:
Date: Sat, 5 Jul 2003 12:39:46 -0500
Subject: Re: Filenames with Umlauts
From: Chris Hanson <email@hidden>
To: email@hidden
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.
Well, I started with bear_precomp, but then pathForResource never found
the thing, just returned nil.
The only way I could make it work was by using
decomposedStringWithCanonicalMapping or its companion
decomposedStringWithCompatibilityMapping (which one is the correct
thing to use ? What is the difference anyway?)
Better would be to use an ASCII constant string for the file name,
When I do:
#define Bear = "B@r"
NSString *bearName = Bear ;
I get: "B 'square root' 'section sign' r". This probably because the
source file is not Unicode (cannot be, compiler does not like this at
all) but Utf-8.
and if you need it to be localized use the localization machinery:
NSString *bearPath
= [mainBundle pathForResource:NSLocalizedString(@"Bear", @"name
of
Bear file") ofType:nil];
I tried this as well.
But NSLocalizedString also gives me an animal which is spelled: "B
'latin small letter a with diaresis' r", and pathForResource does not
understand this.
I do not know, whether this is a bug in pathForResource (which should
automatically decompose filenames) or if this is the way it is supposed
to work.
By the way: NSFileManager seems to automatically decompose filenames.
So NSBundle looks like being particularly fussy about decomposing.
There is a string method: stringByStandardizingPath, but this does
nothing with umlauts, only resolves symbolic names.
Gerriet.
_______________________________________________
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.