Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AS and Unicode characters



HI Yvan,

This is an area that I know nothing about, however, recently I was writing a script to change the pitch of iTunes pieces so that students could play their instruments in normal tuning and I was given some UNICODE that contains the double flat in it.  You might like to see if you can get the code from that.  I'm sorry, but I can not remember who on the list gave me this part of my solution.  

set shift_list to characters of ¬
data utxtD834DD2B266D266E266FD834DD2A» as Unicode text)
set shift_value to choose from list shift_list with prompt ¬
"Choose a pitch shift:" default items shift_list's middle item


On 06/01/2007, at 12:17 AM, KOENIG Yvan wrote:

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:

This email sent to email@hidden



Peter Baxter




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden

References: 
 >AS and Unicode characters (From: KOENIG Yvan <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.