Re: Data to String: what encoding?
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.