Solution for German umlauts and other international characters

1 view
Skip to first unread message

gix2gix

unread,
May 18, 2008, 9:31:14 AM5/18/08
to OFTD
Hi,

I spent some time today on finding a solution for the "international
characters sync-problem". Though it is not a pretty one, it is
working...

You have to insert a couple of lines in the encode_char()-method. If
you need more special mappings have a look at http://isthisthingon.org/unicode/index.phtml
. Enter the trouble making character (i.e. 'ä') in the 'UTF8 String'
textbox and hit enter. Then put a new line in the script with the
UTF-8 (Hex) value (here C3A4), like
{"ä", "%C3%A4"}, ¬


If anybody knows an applescript library to generate UTF-8 hex values,
please let me know. Then we wouldn't have to add each special
character to the map.

Enjoy,
Helge

@Preston: Feel free to add this code to the repository. Ruby URI's
class does a fine job of escaping URIs. Maybe you can use this info.


##############################################
on encode_char(this_char)
-- START OF NEW CODE
set german_Umlaut_Map to {¬
{"ä", "%C3%A4"}, ¬
{"ö", "%C3%B6"}, ¬
{"ü", "%C3%BC"}, ¬
{"Ä", "%C3%84"}, ¬
{"Ö", "%C3%96"}, ¬
{"Ü", "%C3%9C"}, ¬
{"ß", "%C3%9F"} ¬
}
considering case
repeat with a_german_Umlaut_Map in german_Umlaut_Map
if (item 1 of a_german_Umlaut_Map) is (this_char as string) then
return item 2 of a_german_Umlaut_Map
end if
end repeat
end considering
-- END OF NEW CODE

set the ASCII_num to (id of this_char)
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "A", "B", "C", "D", "E", "F"}
set x to item ((ASCII_num div 16) + 1) of the hex_list
set y to item ((ASCII_num mod 16) + 1) of the hex_list
return ("%" & x & y) as string
end encode_char
############################################
Reply all
Reply to author
Forward
0 new messages