Re: Bad Characters from Unicode
Re: Bad Characters from Unicode
- Subject: Re: Bad Characters from Unicode
- From: "Mark J. Reed" <email@hidden>
- Date: Sun, 30 Sep 2007 14:08:36 -0400
Remember: just like parts is parts, bits is bits.
Absent extra labeling, there is no way for any piece of software to
know if a byte whose decimal value is 201 represents the number 201,
the number -55 (if it's a signed byte), or a character in some
one-byte char set... or if it's part of a multi-byte sequence that
could represent even more possibilities...). So when it's unlabeled,
don't blame the receiving software for reacting strangely.
On 9/30/07, Mark J. Reed <email@hidden> wrote:
> Whoa, nelly. Unicode is not the problem. Perhaps you mean "is
> AppleScript support for Unicode ready for prime time?"
>
> But if you leave off the "as unicode text" in the assignment, then
> it's NOT unicode, so I don't see how even the qualified question
> applies here...
>
>
> On 9/30/07, Luther Fuller <email@hidden> wrote:
> > An additional question and answer ...
> >
> > Q:
> > I use the following code to replace sub-strings of multiple
> > 'specialChar's with a single 'specialChar'.
> > If I use only Unicode strings and DO NOT CONVERT to ascii strings,
> > will this code break and, if so, under what conditions?
> >
> > set specialChar to space as Unicode text
> > set i to 0 -- diagnostic
> > repeat until (offset of (specialChar & specialChar) in unicodeText) = 0
> > set AppleScript's text item delimiters to {specialChar & specialChar}
> > set wordList to (text items of unicodeText) as list
> > set AppleScript's text item delimiters to {specialChar}
> > set unicodeText to wordList as text
> > --
> > set i to (i + 1) -- diagnostic
> > if (i > 100) then exit repeat -- diagnostic
> > end repeat -- multiple spaces replaced with single space
> > display dialog i default answer unicodeText
> >
> > A:
> > Yes, this code can break under the right conditions.
> > Breaking this code requires that:
> > 1. the phrase " as Unicode text" is missing from the first line; and
> > 2. the unicode string must contain one of the bad characters; and
> > 3. specialChar must be a space (or perhaps some other unknown
> > character).
> > (In other words, when I try setting specialChar to "!" or "x"
> > or a few other
> > characters, the code does not break.)
> >
> > Is Unicode ready for prime time?
> >
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > AppleScript-Users mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> >
> > Archives: http://lists.apple.com/archives/applescript-users
> >
> > This email sent to email@hidden
> >
>
>
> --
> Mark J. Reed <email@hidden>
>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden