• 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: NSString looses Umlaute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString looses Umlaute


  • Subject: Re: NSString looses Umlaute
  • From: Alexander Reichstadt <email@hidden>
  • Date: Thu, 22 Dec 2011 09:13:00 +0100

Yes, you are right, but it does not make a difference, I tried all encodings. This is a DBF file. From the DBF file format description the header is binary and the rest is ASCII.

I found an older post from someone with French special chars that went lost:
http://stackoverflow.com/questions/4913499/utf8-character-decoding-in-objective-c

But the solution suggested there doesn't work:
NSString *correctString = [NSString stringWithCString:[utf8String cStringUsingEncoding:NSISOLatin1StringEncoding] encoding:NSUTF8StringEncoding];
I know the content of the DBF file. I don't want to write a DBF parser, I only want to read this specific file and it does correctly read all fields and lines, but the Umlaute are still lost. It does work correctly on the Windows side using the browser app for that particular database.

The reason I used the percent-lines was to see what happens to the Umlaute, and inspecting them inbetween changing to and from percent escaped strings they seem to be handled correctly.

Alex

Am 22.12.2011 um 02:18 schrieb Ben Kennedy:

> On 21 Dec 2011, at 4:45 pm, Alexander Reichstadt wrote:
>
>> 	NSString *theContent = [[NSString alloc] initWithData:theData encoding:NSASCIIStringEncoding];
>>       theContent = [[theContent componentsSeparatedByString:@"\r"] objectAtIndex:1];
>>       theContent = [theContent stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
>>       theContent = [theContent stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
>
> Is this really your code?  What is the purpose of the latter two lines?  They are completely reciprocal (i.e. redundant).
>
>> I can even see it handles everything correctly in NSLog, first I see the unicode for an Umlaut, then it converts it to the correct percent value, like like รถ to 94, but when the final NSString is printed to an NSControl, the Umlaute are missing or garbled.
>>
>> The original file is ascii-encoded.
>
> Impossible.  ASCII does not represent any characters with diacritical marks.  Perhaps the original file is ISO-Latin-1 encoded.  You could try using NSISOLatin1StringEncoding.
>
> b
>
> --
> Ben Kennedy, chief magician
> Zygoat Creative Technical Services
> http://www.zygoat.ca
>

_______________________________________________

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

  • Follow-Ups:
    • Re: NSString looses Umlaute
      • From: vincent habchi <email@hidden>
References: 
 >NSString looses Umlaute (From: Alexander Reichstadt <email@hidden>)
 >Re: NSString looses Umlaute (From: Ben Kennedy <email@hidden>)

  • Prev by Date: Re: Get property values of a UI element in an Cross-possess manner without Accessibility APIs ?
  • Next by Date: Re: NSString looses Umlaute
  • Previous by thread: Re: NSString looses Umlaute
  • Next by thread: Re: NSString looses Umlaute
  • Index(es):
    • Date
    • Thread