• 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: Unicode-to-string bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode-to-string bug?


  • Subject: Re: Unicode-to-string bug?
  • From: has <email@hidden>
  • Date: Wed, 24 Nov 2004 19:33:16 +0000

Chris Espinosa wrote:

I'm not sure why " " & (x as string) succeeds and " " & x fails.

Wild guess - please correct if wrong:

1. In the first case, 'x as string' casts the Unicode text to international text; then when AS concatenates a string with international text it coerces the string to international text regardless of which side of the '&' operator it's on, actually returning international text. (Note: AS confusingly reports the class of international text as string, so there's no easy way for users to tell what type the result really is.) This is the sensible approach (e.g. Python always coerces up to unicode when concatenating 8-bit and unicode strings).

2. In the second, AS tries to coerce the right-hand operand to the same class as the left-hand operand, i.e. from Unicode text to string, which errors if there's one or more characters that won't map to the character set used by the string class. This is the dumb approach (AS should follow the same rule as 1. and coerce the string up to Unicode text, regardless of which side of the operator it's on) and something you need to guard against by casting the left-hand operand to Unicode text yourself, i.e. (" " as Unicode text) & x

has

p.s. 'set y to <<data utxt0061>> as Unicode text' doesn't seem to work properly OMM (AS 1.9.1), so there may be other problems here.
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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-to-string bug?
      • From: "Shane Stanley" <email@hidden>
  • Prev by Date: Re: CRON
  • Next by Date: re: cron
  • Previous by thread: Re: Unicode-to-string bug?
  • Next by thread: Re: Unicode-to-string bug?
  • Index(es):
    • Date
    • Thread