AppleScript名:ASOCで文字を逆順に v2(CJK文字などマルチバイト対応) |
— Created 2015-09-01 by Takaaki Naganoya — Modified 2015-09-01 by Shane Stanley –Consider CJK Characters & Emoji –http://stackoverflow.com/questions/6720191/reverse-nsstring-text use AppleScript version "2.4" use scripting additions use framework "Foundation" set aUUID to (current application’s NSUUID’s UUID()’s UUIDString()) as text –> "46EF17B7-CB3E-4DD9-BA8A-013D3B30A80A" set aUUID to "😀😐" & aUUID & "😀😐" –> "😀😐46EF17B7-CB3E-4DD9-BA8A-013D3B30A80A😀😐" set revUUID to reversedStr(aUUID) as text –> "😐😀A08A03B3D310-A8AB-9DD4-E3BC-7B71FE64😐😀" on reversedStr(paramStr as text) set aStr to current application’s NSString’s stringWithString:paramStr set strLength to aStr’s |length|() set revStr to current application’s NSMutableString’s stringWithCapacity:strLength set charIndex to strLength – 1 repeat while charIndex > -1 set subStrRange to aStr’s rangeOfComposedCharacterSequenceAtIndex:charIndex revStr’s appendString:(aStr’s substringWithRange:subStrRange) set charIndex to (location of subStrRange) – 1 end repeat return revStr end reversedStr |
More from my site
(Visited 25 times, 1 visits today)