AppleScript名:テキストからリガチャーを削除する v2 |
— Created 2017-01-17 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set inputStringWithLigatures to "ꜲꜳÆæꜴꜵꜶꜷꜸꜹꜺꜻꜼꜽffffifflfiflŒœꝎstꜨꜩᵫꝠꝡ" & "LJLjNJNjnjDZDzdzIJij" set aRes to removeLigaturesFromString(inputStringWithLigatures) of me –> "AAaaAEaeAOaoAUauAVavAVavAYayffffifflfiflOEoeOOstTZtzueVYvyLJLjNJNjnjDZDzdzIJij" on removeLigaturesFromString(inputStringWithLigatures) set theString to current application’s NSString’s stringWithString:inputStringWithLigatures # Convert what may be done applying transform "ÆæffffifflfiflŒœᵫ" & "LJLjNJNjnjDZDzdzIJij" set inputStringWithLigatures to (theString’s stringByApplyingTransform:"Latin-ASCII" |reverse|:false) as text # Treat the remaining ligatures set searchStrings to {"Ꜳ", "ꜳ", "Ꜵ", "ꜵ", "Ꜷ", "ꜷ", "Ꜹ", "ꜹ", "Ꜻ", "ꜻ", "Ꜽ", "ꜽ", "Ꝏ", "Ꜩ", "ꜩ", "Ꝡ", "ꝡ"} — if you find others, add them here set replaceStrings to {"AA", "aa", "AO", "ao", "AU", "au", "AV", "av", "AV", "av", "AY", "ay", "OO", "TZ", "tz", "VY", "vy"} — if you find others, add them here set saveTID to AppleScript’s text item delimiters considering case set i to 0 repeat with lig in searchStrings set i to i + 1 set AppleScript’s text item delimiters to {lig} set inputStringWithLigatures to text items of inputStringWithLigatures set AppleScript’s text item delimiters to {item i of replaceStrings} set inputStringWithLigatures to inputStringWithLigatures as text end repeat end considering set AppleScript’s text item delimiters to saveTID return inputStringWithLigatures end removeLigaturesFromString |
More from my site
(Visited 25 times, 1 visits today)