Re: Diacritical characters -> *.strings file problem
Re: Diacritical characters -> *.strings file problem
- Subject: Re: Diacritical characters -> *.strings file problem
- From: Stefan Pantke <email@hidden>
- Date: Sun, 25 Jan 2004 05:10:47 +0100
Thanks, David!
I created an example *.strings file containing:
"ä" = "d";
"ö" = "v";
"ü" = "|";
"ß" = "_";
Then I defined this index in the app to access all *.strings entries
NSArray *diacrits = [NSArray arrayWithObjects:
@"ä",
@"ö",
@"ü",
@"ß",
nil];
Using this code
for( n=0; n<[diacrits count]; n++ ) {
NSString *umlaut = [[NSBundle mainBundle]
localizedStringForKey:[diacrits objectAtIndex:n]
value:@"[?]"
table:@"entities"];
NSLog( @"Mapping %@ -> %@", umlaut, [diacrits objectAtIndex:n]
);
targetCode = [self replaceIn:targetCode oldString:umlaut
withNewString:[diacrits objectAtIndex:n] ];
}
I recieved this output:
2004-01-25 05:03:07.617 Server[5534] Mapping d -> ä
2004-01-25 05:03:07.619 Server[5534] Mapping v -> ö
2004-01-25 05:03:07.623 Server[5534] Mapping | -> ü
2004-01-25 05:03:07.625 Server[5534] Mapping [?] -> ß
The first 3 replacement is fine.
The fourth replacement isn't. But why?
Do I have to escape some special charactes in the *.strings file?
Any hints?
Thx,
Stefan
Am 25.01.2004 um 03:09 schrieb David Reed:
Stefan,
I believe the rule is that you can't use non ASCII characters in
constant CFStrings (created with CFSTR()). CFString is Unicode, so it
can certainly handle umlauts. The best workaround I know of is to
replace the CFSTR("d whatever") call with
CFCopyLocalizedString(CFSTR("a whatever")) and have the line
"a whatever" = "d whatever";
in your Localizable.strings. Keep in mind though that the result of
CFCopyLocalizedString must be released - unlike CFSTR.
HTH,
David.
On Saturday, Jan 24, 2004, at 20:56 US/Eastern, Stefan Pantke wrote:
Hi,
I need to find diacritical charactes (e.g. d (Umlaute)) and replace
them in some
fashion.
XCode reports a
non-ASCII string in CFString .
Thus, I suppose, non-ascii characters are not allowed.
How may I inter these special characters? By ASCII Code? Or
as simple C string - not as Obj-C @-string?
stefan
_______________________________________________
MacOSX-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/macosx-dev
_______________________________________________
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.