• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Diacritical characters -> *.strings file problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:

"&auml;" = "d";
"&ouml;" = "v";
"&uuml;" = "|";
"&szlig;" = "_";

Then I defined this index in the app to access all *.strings entries

NSArray *diacrits = [NSArray arrayWithObjects:
@"&auml;",
@"&ouml;",
@"&uuml;",
@"&szlig;",
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 -> &auml;
2004-01-25 05:03:07.619 Server[5534] Mapping v -> &ouml;
2004-01-25 05:03:07.623 Server[5534] Mapping | -> &uuml;
2004-01-25 05:03:07.625 Server[5534] Mapping [?] -> &szlig;

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.

  • Follow-Ups:
    • Re: Diacritical characters -> *.strings file problem [SOLVED]
      • From: Stefan Pantke <email@hidden>
  • Prev by Date: Re: Any new/updated Cocoa books soon?
  • Next by Date: [APP IDEA] Desktop Background Scripting
  • Previous by thread: Re: drawing view pieces into images
  • Next by thread: Re: Diacritical characters -> *.strings file problem [SOLVED]
  • Index(es):
    • Date
    • Thread