Re: String works, variable that's a string does not. - Unicode conversion
Re: String works, variable that's a string does not. - Unicode conversion
- Subject: Re: String works, variable that's a string does not. - Unicode conversion
- From: Bradford Sherman <email@hidden>
- Date: Thu, 29 Apr 2004 11:40:33 -0700
I've been following this discussion and found that it solved a problem
that's probably cost me a day trying to understand what is going on. A
script that worked fine when reading a text file containing a list of
file paths and then passed these string on to another application (that
doesn't support Unicode) worked fine. When I tried to generate the same
list using the list Folder command passing the list of Unicode strings
did not work and I had no idea what was going wrong as the strings
appeared identical in the event log window.
Is there a fast way to coerce Unicode to ASCII in MacOS X 10.3.3 ?
Michelle Steiner's solution is the only one that works for me so far
but it isn't very quick to execute
set text_returned to text_returned
set temp to ""
repeat with loop from 1 to length of text_returned
set temp to temp & (ASCII character of (ASCII number of character
loop of text_returned))
end repeat
set text_returned to temp
I tried to put Michelle's code into a separate procedure where
text_returned was passed as an argument and for some reason the class
of temp is Unicode text when it occurs in my procedure but it is a
String when included in line with the calling procedure. I can
understand why thetext retains the Unicode text class it has from the
calling procedure but I'm baffled by why the class of temp was returned
as Unicode?
on makeASCII(thetext)
set thetext to thetext
set temp to ""
repeat with loop from 1 to length of thetext
set temp to temp & (ASCII character of (ASCII number of character
loop of thetext))
end repeat
set thetext to temp
display dialog "temp is type " & (class of thisFile as text) buttons
{"OK"} default button 1
display dialog "the text is type " & (class of thisFile as text)
buttons {"OK"} default button 1
end makeASCII
The first few times I ran the script the dialogs listed the class as
Unicode text. Now that I've mucked around with it a bit I'll be
buggered if they don't list the class as string now.
Nigel Garvey suggested
try
set text_returned to <<class ktxt>> of (text_returned as record)
end try
but this doesn't seem to work for me.
Brad Sherman
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.