2011-03-03 12 views

答えて

0

Pythonではもっと簡単かもしれません。ここでは、テキストファイルを読み込んで2つの出力ファイルを作成するスクリプトを示します.1つはlow-ASCIIで、もう1つはその他のものです。 PythonのサポートがVimでコンパイルされている場合は、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管理区域 

それはあなたがやりたいのか?

要旨として保存:https://gist.github.com/855545

+0

ありがとう!それはまさに私が欲しいものです! –

関連する問題