I have a .csv file downloaded from Google Drive in a codification that doesnt recognize accented characters (spanish characters).
With the VIM editor for Windows I'm able to solve this problem by opening the file (vim spanish.csv) and then inside the file type
:write ++enc=utf-16 spanish-2.csv
Now I need to create a .bat or .ps1 to automatically do this for me. How can I do this?
P.D.: I've tried using iconv and I can't convert the file that I download from Google Drive since I don't know in with codification it is. I tried:
iconv -f ANSI:X3.4-1968 -t UTF-8 spanish.csv > spanish-2.csv
iconv -f ANSI:X3.4-1986 -t UTF-8 spanish.csv > spanish-2.csv
iconv -f ASCII -t UTF-8 spanish.csv > spanish-2.csv
And many other encodings but it says that the file can't be converted.
When you've opened the spanish.csv
source file within Vim,
:setlocal fileencoding?
should tell you the detected encoding. There are also third-party tools like enca
that can do this detection. You then only potentially need to translate the encoding name into the format expected by iconv
.
You can also directly use Vim for the conversion; Ex commands can be specified on the command-line via -c {cmd}
:
vim -c "write ++enc=utf-16 spanish-2.csv" -c "quit" spanish.csv
With the use of :argdo
, and a file name of %:r-2.%:e
, you can even pass multiple source files to a single Vim instance for conversion.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다