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 ;-((