• 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
Unicode or ascii
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unicode or ascii


  • Subject: Unicode or ascii
  • From: Luther Fuller <email@hidden>
  • Date: Sun, 2 Apr 2006 11:44:08 -0500

I've just spent hours trying to find out why my script reads some files correctly and not others.
The original snippet is ...


set refNr to open for access fileRef --------< open the file
set textList to paragraphs of (read refNr)
close access refNr -----------------------------< close the file
display dialog (item 1 of textList) --DIAGNOSTIC 1
item 1 of textList
display dialog character 1 of the result & return & character 2 of the result & ... --DIAGNOSTIC 2


Files that read correctly are mail saved from Eudora. Those that don't read correctly are mail files saved from Mail. These files reveal in the diagnostics that every displayed character is preceeded by a null character.

If I change the 2nd line to ...
set textList to paragraphs of (read refNr as Unicode text)
then Mail files read correctly, but now the diagnostics reveal that Eudora files contain Chinese characters.


There seems to be a problem with the 'read' command. I would expect that it would return ascii as ascii and unicode as unicode. But it seems to be reading bytes, sometimes incorrectly or double-bytes, sometimes incorrectly, if I explicitly use 'as Unicode text'.

Once the text is read incorrectly, it is NOT possible to convert the text.

The only workaround I know would be to determine, before reading the file, if it's unicode or ascii. I don't know if this is possible. Anyone?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Unicode or ascii
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: Folder Actions technical questions
  • Next by Date: Re: Folder Actions technical questions
  • Previous by thread: Re: Folder Actions technical questions
  • Next by thread: Re: Unicode or ascii
  • Index(es):
    • Date
    • Thread