[file encoding] improved code & modified for file_edit & text_diff