文字列のエンコードを変換する
作者: 小見 拓
—
最終変更
2012年01月08日 12時10分
文字列のエンコードを変換する
- iconvを使用して変換
:let text = ..... :let from = "utf-8" :let to = "euc-jp" :let encoded = iconv(text, from, to) :echo encoded "# => utf-8の文字列をeuc-jpの文字列に変換して出力
- vimエディタ内部で使用しているエンコーディングは「&encoding」で取れるので、次の方法で指定エンコーディングのテキストを読める形式にできる
:let text = ..... :let from = "utf-8" :let encoded = iconv(text, from, &encodings) :echo encoded "# => utf-8の文字をvimエディタ内部で使用しているエンコーディングの文字に変換して出力
- あるテキストを指定エンコーディングの文字列に変換する
:let text = ..... :let to = "utf-8" :let encoded = iconv(text, &encoding, to) :echo encoded "# => utf-8のエンコーディングの文字列に変換して出力
Recent Comments
ありがとうございます!
http://nanasi.jp/articles/howto/editing/visualcursor-endtoend.html · 8 years ago
知りませんでした。有難うございました。
http://nanasi.jp/articles/howto/file/open-with-format.html · 9 years ago
<c-f>1ページ分、下にスクロールする<c-b>1ページ分、上にスクロールする
どっちも逆です。
http://nanasi.jp/articles/howto/user-manual/user-manual-motion.html · 10 years ago
set 使用時に : で閉じるのを忘れて右往左往してました。
http://nanasi.jp/articles/howto/file/modeline.html · 11 years ago
やっぱり日本語の方が早いっす。
http://nanasi.jp/articles/howto/help/help_ja.html · 12 years ago