AppleScript名:実体参照している文字列をデコードする(ASOC) |
— Created 2017-01-18 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –http://piyocast.com/as/archives/4568 set aStr to "龍馬伝" set aRes to decodeCharacterReference(aStr) of me –> "龍馬伝" set aStr to "\"第2エア\"" set aRes to decodeCharacterReference(aStr) of me –> "\"第2エア\"" on decodeCharacterReference(aStr) set anNSString to current application’s NSString’s stringWithString:aStr set theData to anNSString’s dataUsingEncoding:(current application’s NSUTF16StringEncoding) set styledString to current application’s NSAttributedString’s alloc()’s initWithHTML:theData documentAttributes:(missing value) set plainText to (styledString’s |string|()) as string return plainText end decodeCharacterReference |
More from my site
(Visited 29 times, 1 visits today)