• 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: AS and Unicode characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: AS and Unicode characters


  • Subject: RE: AS and Unicode characters
  • From: KOENIG Yvan <email@hidden>
  • Date: Fri, 5 Jan 2007 21:57:49 +0100


Le 5 janv. 07 à 18:38:46, Doug McNutt a écrit :

At 18:21 +0100 1/5/07, KOENIG Yvan wrote:
which correctly wrote "FE FF D8 34 DD 2B" in the temporary file.
Alas, when reading it I got an infamous "?".
I assumes that I made something wrong but what ?

It's likely that your display font doesn't support the code point.

Lucinda Grande is a good try. Does the code point display in the International preferences panel?
--


Yes, the char exists in Lucida Grande.

It is MUSICAL SYMBOL DOUBLE FLAT

I just find a way to get a correct result:

-- [SCRIPT]
on getUnicode(h)
 local t, f, p, v, hi, hihi, lo, lohi, c
 if (count of h) < 4 then set h to ¬
 text -4 thru -1 of ("0000" & h)
 if (count of h) = 4 then
 set c to (ASCII character (my decimal(h's text 1 thru 2))) & ¬
 (ASCII character (my decimal(h's text 3 thru 4)))
 else
 set {p, v} to {"0123456789ABCDEF", 0}
 set h to (p's character ((offset of (h's character 1) in p) - 1)) & ¬
 text 2 thru 5 of h (* h = h - $10000 *)
 repeat with k in h
 set v to (v * 16) + (offset of k in p) - 1
 end repeat
 set hi to v div 1024
 set lo to v - (hi * 1024)
 set hi to 55296 + hi (* 55296 = $D800 *)
 set lo to 56320 + lo (* 56320 = $DC00 *)
 set hihi to hi div 256
 set hi to hi - (hihi * 256)
 set lohi to lo div 256
 set lo to lo - (lohi * 256)
 set c to (ASCII character hihi) & ¬
 (ASCII character hi) & ¬
 (ASCII character lohi) & ¬
 (ASCII character lo)
 end if
 set t to ((path to desktop) as text) & "temp1"
 set f to open for access file t with write permission
 set eof of f to 0
 write (ASCII character 254) & ¬
 (ASCII character 255) & c to f
 close access f
 tell application "TextEdit"
 activate
 open file t
 set the clipboard to (text of document 1) as Unicode text
 close window 1
 end tell
end getUnicode

on decimal(h)
 local p
 set p to "0123456789ABCDEF"
 return ((offset of (h's character 1) in p) - 1) * 16 + ¬
 (offset of (h's character 2) in p) - 1
end decimal

my getUnicode("1D12B")

(* FE FF D8 34 DD 2B *)
-- [/SCRIPT]

I wished to find a way free from TextEdit but at this time I didn't get it ;-((

Yvan KOENIG


_______________________________________________ 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/mailman//archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Re: AS and Unicode characters
  • Next by Date: [ANN] Boston AppleScript User Group News
  • Previous by thread: Re: AS and Unicode characters
  • Next by thread: Re: AS and Unicode characters
  • Index(es):
    • Date
    • Thread