• 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 18:21:57 +0100


Le 5 janv. 07 à 15:27:37, Mark J. Reed a écrit : …

3. The first digit comes from the high surrogates area, which starts at D800. Just add: D800 + 34 = D834. That's the first "character" output.

4. The second digit comes from the low surrogates area at DC00.  DC00
+ 12B = DD2B.


Thank you Mark.

I tried to code your explanations.

I got

-- [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 ofh (* 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 hilo to hi - (hihi * 256)
 set lohi to lo div 256
 set lolo to lo - (lohi * 256)
 set c to (ASCII character hihi) & ¬
 (ASCII character hilo) & ¬
 (ASCII character lohi) & ¬
 (ASCII character lolo)
 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
 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 D8 34 DD 2B *)
-- [/SCRIPT]

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 ?

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: "Steven D. Majewski" <email@hidden>
    • Re: AS and Unicode characters
      • From: Doug McNutt <email@hidden>
References: 
 >AS and Unicode characters (From: KOENIG Yvan <email@hidden>)
 >Re: AS and Unicode characters (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Quirks of Annotate script
  • Next by Date: Re: AS and Unicode characters
  • Previous by thread: Re: AS and Unicode characters
  • Next by thread: Re: AS and Unicode characters
  • Index(es):
    • Date
    • Thread