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

AS and Unicode characters


  • Subject: AS and Unicode characters
  • From: KOENIG Yvan <email@hidden>
  • Date: Fri, 5 Jan 2007 14:17:03 +0100

Hello

Trying to help a friend, I wrote a script trying to grab an UNICODE character starting from its hexadecimal code.

This short script

-- [SCRIPT]
on getUnicode(h)
  local t, f
  if (count of h) = 1 then
  set h to "000" & h
  else if (count of h) = 2 then
  set h to "00" & h
  else if (count of h) is in {3, 5} then
  set h to "0" & h
  end if
  set t to ((path to desktop) as text) & "tempk"
  set f to open for access file t with write permission
  set eof of f to 0
  write (ASCII character 254) & ¬
  (ASCII character 255) & ¬
  (ASCII character (my decimal(h's text 1 thru 2))) & ¬
  (ASCII character (my decimal(h's text 3 thru 4))) to f
  if (count of h) > 4 then write (ASCII character (my decimal(h's
text 5 thru 6))) to f
  close access f
  set the clipboard to (read (t as alias) as Unicode text)
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 01 D1 2B *)
-- [/SCRIPT]
seemed OK as it correctly writes the sequence "FE FF 01 D1 2B" in the temporary file.


Alas, when pasting in TextEdit I discovered that the code only grabbed the first two bytes 01D1 giving to me an infamous
(LATIN CAPITAL LETTER O WITH CARON whose code is (01D1)
when I wanted a
MUSICAL SYMBOL DOUBLE FLAT (01D12B).


Is one of you aware of some workaround?

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
  • Follow-Ups:
    • Re: AS and Unicode characters
      • From: Peter Baxter <email@hidden>
    • Re: AS and Unicode characters
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: Re: Unexpected Finder window
  • Next by Date: Re: AS and Unicode characters
  • Previous by thread: Re: Unexpected Finder window
  • Next by thread: Re: AS and Unicode characters
  • Index(es):
    • Date
    • Thread