How to change the encoding of an existing file using Vim

here is the subtitle file at http://subscene.com/subtitles/crank/farsi_persian/281992 . if you download it, you will see several codes such as:

1
00:02:05,360 --> 00:02:07,430
åßÊæÑ¡ ãÇ åäæÒ ÏÇÑíã ãí ÑÎíã¿
ÎæÈå

2
00:02:07,600 --> 00:02:10,956
áíæÓ! ãÇ ÏÇÑíã í ÇÑ ãíäíã Èå ¿
æ Ïíå åí æÞÊ ãä Ñæ ÕÏÇ äãíÒäí

thing i expect:

1
00:02:05,360 --> 00:02:07,430
هكتور، ما هنوز داريم مي چرخيم؟
خوبه

2
00:02:07,600 --> 00:02:10,956
چليوس! ما داريم چي کار ميکنيم بچه ؟
و ديگه هيچ وقت من رو صدا نميزني

I achieved this by changing the file extension from srt to txt, opening it with a Chrome browser, chenging encoding to arabic windows and re-saving the contents of the file, highlighting all the text.

I do not know how to do this with vim or shell script. I tried :write ++enc=utf-8 russian.txtor set encodingor set fileencoding, but no luck.

thanks mona

+5
source share
1 answer

in vim :

, . :

:e ++enc=cp1256

utf-8,

:w ++enc=utf-8

:

iconv -cf WINDOWS-1256 -t utf-8 problem.srt -o correct.srt
+6

All Articles