Re: 'sort' command-alternative?
Re: 'sort' command-alternative?
- Subject: Re: 'sort' command-alternative?
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 06 Oct 2002 10:29:32 -0700
On 10/6/02 6:04 AM, "John Delacour" <email@hidden> wrote:
>
At 2:07 am -0700 6/10/02, Paul Berkowitz wrote:
>
>
> Is there any way in AppleScript to get Unicode number of a given character?
>
> 'AE Print' in Script Debugger result window gives the double-byte hex form:
>
> perhaps there's a way to do that in AppleScript itself? ('as data' doesn't
>
> do it.) Those numbers are quite sortable after converting to decimal.
>
>
>
There may be a simpler way but this script will take a Unicode
>
character (in this case from a TextEdit window), convert it to a
>
decimal html entity anddisplay it in your browser.
I tried it first with "a", which didn't work too well:
--> "�" displayed in a new TextEdit document
>
>
>
tell app "TextEdit" to set s to get character 1 of document 1
--> "a" [as Unicode text]
>
set f to "tmp:junk.txt"
>
set f2 to "tmp:junk.html"
>
>
set s to TECConvertText s fromCode "UNICODE-2-0" toCode "UNICODE-2-0-UTF-8"
>
set s to TECConvertText s fromCode "UNICODE-2-0-UTF-8" toCode "UNICODE-2-0"
--> "a" [as Unicode text]
What does this do, John? Why convert twice, back to where it came from?
>
--
>
open for access file f with write permission
>
set eof file f to 0
>
write s to file f
>
close access file f
>
--
>
set pair to read file f
--> "a" [as plain text, new method]
>
set n to 256 * (ASCII number (character 1 of pair))
--> 0
>
set n to n + (ASCII number (character 2 of pair))
--> 0
>
set htmlChar to "&#" & n & ";"
--> "�"
>
display dialog htmlChar
--> "�"
>
--
>
open for access file f2 with write permission
>
write "<html>" & htmlChar to file f2
>
close access file f2
>
tell app "Finder" to open file f2
--> "�" in new TextEdit doc, Times font (my default for RTF styled text),
interesting doc icon in window bar
>
>
>
I can't get Smile to convert it, so I've used the TEC osax.
I got that.
--
Paul Berkowitz
_______________________________________________
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.