• 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: Mike Abdullah <email@hidden>
  • Date: Thu, 22 Dec 2011 17:01:19 +0000

On 22 Dec 2011, at 15:54, Alexander Reichstadt wrote:

> Thanks, but I  have not tried. My thinking went along the lines of if I read the string directly from the URL I have no control over what encoding is being used for reading or it defaults to something. If I first read as data, I can do with those bytes as I please. The DBF file is not in one consistent encoding from start to finish. The DBF file format documentation says the header is in binary, then there is a linefeed (\r), then there is the body. Each field has a fixed length, wether used or not doesn't matter, the unused rest is filled with spaces.
>
> So, I read the file as data, stringily it as DOSLatin1, split it at the linefeed and read the body according to the field definitions I am given. They are guaranteed, so maybe some day I get around to writing a nice DBF parser, but until then I go by the guaranteed field lengths.

If your first step after reading the data is create a string from it, then you might as well use NSString directly. -[NSString initWithContentsOfURL:encoding:error:] does exactly what you are doing right now, and potentially more memory-efficiently.

That said, either of these may not be great since it's possible something in the binary header might cause NSString to fail. Instead you should really do:

1. Read the data into memory
2. Locate where the text begins
3. Split out a new data object containing just the text data
4. Create a string from that data_______________________________________________

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

References: 
 >NSString looses Umlaute (From: Alexander Reichstadt <email@hidden>)
 >Re: NSString looses Umlaute (From: Ben Kennedy <email@hidden>)
 >Re: NSString looses Umlaute (From: Alexander Reichstadt <email@hidden>)
 >Re: NSString looses Umlaute (From: vincent habchi <email@hidden>)
 >Re: NSString looses Umlaute (From: Alexander Reichstadt <email@hidden>)
 >Re: NSString looses Umlaute (From: Vincent Habchi <email@hidden>)
 >Re: NSString looses Umlaute (From: Alexander Reichstadt <email@hidden>)
 >Re: NSString looses Umlaute (From: Jean-Daniel Dupas <email@hidden>)
 >Re: NSString looses Umlaute (From: Alexander Reichstadt <email@hidden>)
 >Re: NSString looses Umlaute (From: Mike Abdullah <email@hidden>)
 >Re: NSString looses Umlaute (From: Alexander Reichstadt <email@hidden>)

  • Prev by Date: Re: presentingViewController docs patently false
  • Next by Date: Re: Debugging hints
  • Previous by thread: Re: NSString looses Umlaute
  • Next by thread: Re: NSString looses Umlaute
  • Index(es):
    • Date
    • Thread