我正在使用包含罗马字符和亚洲字符的文档,我希望将它们中的每一个单独放在两个独立的文件中并保留其原始结构,是否可能?
由于
答案 0 :(得分:0)
在Python中可能更容易。这是一个读取文本文件并创建两个输出文件的脚本:一个使用低ASCII,另一个使用其他所有文件。如果您在Vim中编译了Python支持,则还应该可以在Vim中使用以下内容(只需进行少量更改)。
import codecs
mixedInput = codecs.open('mixed.txt', 'r', 'utf-8')
lowAsciiOutput = codecs.open('lowAscii.txt', 'w', 'utf-8')
otherOutput = codecs.open('other.txt', 'w', 'utf-8')
for rawline in mixedInput:
line = rawline.rstrip()
for c in line:
if ord(c) < 2**7:
lowAsciiOutput.write(c)
else:
otherOutput.write(c)
otherOutput.write('\n')
lowAsciiOutput.write('\n')
mixedInput.close()
lowAsciiOutput.close()
otherOutput.close()
示例输入文件(mixed.txt):
欢迎来到Mifos管理区域
这样做你想要的吗?