我正在尝试找一个写俄语的解决方案,但是拉丁字符(参见translit.ru的想法)
我的想法是写一个像AppleScript一样的东西: - >选定的文字 - >转换它
Hpw dp我在ActionScript中使用字符串替换字符?
答案 0 :(得分:1)
用西里尔字符转移拉丁语是第一个重要问题。它是Unicode还是拉丁语和西里尔字符编码之间的转换?
你已经要求一个例子来逐字符替换我可以举例说明它是如何工作的。当然还有许多其他示例,但在这里您可以根据自己的喜好更改源列表和目标列表。
set theString to "Hello World!"
set sourceList to "abcdefghijklmnopqrstuvwxyz"
set targetList to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set newString to {}
repeat with theChar in theString
set o to offset of theChar in sourceList
if o is 0 then
set end of newString to contents of theChar
else
set end of newString to character o of targetList
end if
end repeat
return newString as string