Re: Unicode and ASCII issues
Re: Unicode and ASCII issues
- Subject: Re: Unicode and ASCII issues
- From: julifos <email@hidden>
- Date: Thu, 19 Dec 2002 10:07:46 +0000
>
When working with ASCII text, one can convert a letter to its MacRoman
>
numerical equivalent, and back, for example:
>
>
return ASCII number of "a"
>
--> 97
>
return ASCII character 97
>
--> "a"
>
>
I need to be able to do this same action with Unicode, because I need
>
to decompose some Hangul characters, which are highly logically
>
organized in Unicode, so, given the number, I could figure out the
>
composition of the syllable. (eg, break "an-nyeong" into "a" "n" "n"
>
"yeo" "ng").
>
>
Is there any way to get the Unicode number of a character and/or (in
>
case I need it later) get a Unicode character based on its number? If
>
there isn't such a command....Chris N./E.? Tim? Any chance of this in
>
an update for AppleScript?
>
>
I've searched the archives and think I saw the question asked once
>
before, but never found an answer to the question.
I don't understand so good your question, but perhaps some piece of this
subroutine can help you... (I think it won't work for *all* chars...)
Also, you can try "Unicode osax" (
http://www.merzwaren.com/) or any of
iimori's osaxen (
http://www.bekkoame.ne.jp/~iimori/indexSoftware.html)
Bye!
JJ
__________________________
set ChartToTranslat to "a" -- "a-acute" or "ascii 135"
charToISOLatin1(ChartToTranslat, "ascii")
--> "7" (this is ascii character 255)
charToISOLatin1(ChartToTranslat, "dec")
--> 225
charToISOLatin1(ChartToTranslat, "hex")
--> "E1"
on charToISOLatin1(this_char, desiredResult)
if (length of (this_char as text) is not 1) then set desiredResult to ""
-- only one character or force error
this_char as Unicode text
{{coercionTrick:result}}
set convertedChar to last character of (result as string)
if desiredResult is "ascii" then
return convertedChar
else if desiredResult is "dec" then
return ASCII number of convertedChar
else if desiredResult is "hex" then
convertedChar as C string
try
result * 5
on error msg
return text from character 22 of msg to character 23 of msg
end try
else
error "The handler must be as follow:" & return & return &
"charToISOLatin1(single_string_item,string)" & return & return & "where
\"single_string_item\" is any ascii character and \"string\" is one of
\"ascii\", \"dec\" or \"hex\""
end if
end charToISOLatin1
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.