Save some time converting umlauts and special characters to HTML
Save some time converting umlauts and special characters to HTML
- Subject: Save some time converting umlauts and special characters to HTML
- From: Martin Michel <email@hidden>
- Date: Fri, 22 Mar 2002 00:41:49 +0100
Hi,
as I needed a HTML-export function in my AS-S app I wrote the following
routine which converts umlauts and other special characters to HTML
code. It took me two hours to figure it out (yes, I am an amateur) so
perhaps someone can use it and save some time.
If this email is messed up I can send you an compiled and stuffed script
on demand via email.
Yours,
Martin, the guy that created the famous Charts-O-Mat
--***
property SZListe : {"C", "\"", "<", ">", "B!", "B"", "B#", "B%", "B'", "B(",
"B)", "B*", "B+", "B,", "B.", "B0", "B1", "B4", "B5", "B6", "B7", "B8", "B:", "B;",
"B?", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C ", "C
", "C", "C",
"C
", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C",
"C ", "C!", "C"", "C#", "C$", "C%", "C&", "C'", "C(", "C)", "C*", "C+", "C,", "C-",
"C.", "C/", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C:", "C;", "C<",
"C?", "b"", "b", "b"", "b,", "b", "b", "b", "b", "b", "b"}
property ESListe : {"ß", """, "<", ">", "¡",
"¢", "£", "¥", "§", "¨", "©", "ª",
"«", "¬", "®", "°", "±", "´", "µ",
"¶", "·", "¸", "º", "»", "¿",
"À", "Á", "Â", "Ã", "Ä", "Å",
"Æ", "Ç", "È", "É", "Ê", "Ë",
"Ì", "Í", "Î", "Ï", "Ñ", "Ò",
"Ó", "Ô", "Õ", "Ö", "Ø", "Ù",
"Ú", "Û", "Ü", "à", "á", "â",
"ã", "ä", "å", "æ", "ç", "è",
"é", "ê", "ë", "ì", "í", "î",
"ï", "ñ", "ò", "ó", "ô", "õ",
"ö", "÷", "ø", "ù", "ú", "û",
"ü", "ÿ", "•", "⁄", "™", "€", "‘",
"’", "‚", "“", "”", "„"}
set theText to "Whatever you like to test"
considering case, diacriticals and punctuation
if theText is not "" then
if theText contains "&" then
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"&"}
set ls to text items of theText
set AppleScript's text item delimiters to {"&"}
set theText to ls as string
set AppleScript's text item delimiters to oldDelims
end if
repeat with i from 1 to the count of items in SZListe
if theText contains item i of SZListe then
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to item i of SZListe
set ls to text items of theText
set AppleScript's text item delimiters to item i of ESListe
set theText to ls as string
set AppleScript's text item delimiters to oldDelims
end if
end repeat
end if
end considering
--***
_______________________________________________
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.