0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TDM-GCC-64でlibiconvを使う

Last updated at Posted at 2017-11-23

C言語で文字コード変換したいと思った。
iconvが定番らしい。あるものは使おう。

入手

https://www.gnu.org/software/libiconv/ からダウンロードする。
2017/11/23現在の最新版は「libiconv-1.15.tar.gz」。

インストール

$ which gcc
/c/TDM-GCC-64/bin/gcc
$ ./configure prefix=/c/TDM-GCC-64 --enable-static --disable-shared
$ make
$ make install

参考: 猫科研究所 - 今更MinGW 2009.06(7) iconv,libxml2

使ってみる

iconv - Wikipediaのサンプルコードを使ってみた。

$ gcc main.c -liconv
$ cat sjis.txt # SJISは文字化けする
▒▒▒▒▒▒▒▒▒▒
$ ./a.exe      # SJIS→UTF8変換
$ cat utf8.txt # UTF8は表示できる
あいうえお

たしかに変わった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?