• 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: Data to String: what encoding?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Data to String: what encoding?


  • Subject: Re: Data to String: what encoding?
  • From: Randall Crenshaw <email@hidden>
  • Date: Mon, 16 Sep 2002 05:13:54 -0700 (PDT)

--- Ondra Cada <email@hidden> wrote:
>
> On Sunday, September 15, 2002, at 09:38 , Douglas
> Davidson wrote:
>
> > It is impossible in principle to determine the encoding
> used for an
> > arbitrary file. If the file contains sufficient
> amounts of
> > natural-language text, then a human reader can usually
> determine the
> > intended encoding, but it is easy to produce files for
> which many
> > different encodings might have been used. Any method
> of the sort you
> > propose would be no more than a reasonable guess.
>
> Well, if the text is not entirely trivial and if there is
> a spellchecker,
> you can guess with a pretty low probability of a miss.
>
> That is, of course, not a contradiction of what you
> written -- for special
> cases, there should *always* be a way for the user to
> force the encoding
> manually, for case the heuristics guessed wrong.

Um, ok - now I'm really confused. Just what is an
'encoding' anyway? I have been assuming that an encoding
is something like ASCII where ('A' == 0x0101) except that
in some other encoding, ('A' == 0x01000101 ) or something
like that. (Byte values not intended to be accurate.) So,
as a pure bytestream, there would be no internal clues, but
if you say "this is text" there should be some inherent
characteristics of the bytestream.

For example, if I read the file from disk into an NSString,
I can then convert to NSData using -fastestEncoding. This
would appear to solve the problem, except there is no easy
reverse conversion. If I read an NSData first, I am stuck
hitting the disk again to get it into a string. So how
does NSString pick an encoding? Why can it read from disk
but not from NSData?

Sorry - I'm sure it's apparent I'm at the edge of my
empirical understanding of things. Any books that cover
this stuff?

Thanks,
Randall
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
_______________________________________________
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: Data to String: what encoding?
      • From: Todd Blanchard <email@hidden>
    • Re: Data to String: what encoding?
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Data to String: what encoding? (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Get default Browser and Mail Client
  • Next by Date: Re: Data to String: what encoding?
  • Previous by thread: Re: Data to String: what encoding?
  • Next by thread: Re: Data to String: what encoding?
  • Index(es):
    • Date
    • Thread