Thursday, August 18, 2011, 20:33 - Blog網誌
Posted by Administrator
iconv程序以一個編碼讀取文本,並輸出文本Posted by Administrator
另一個編碼。 如果沒有給出輸入文件,或者如果它被賦予
破折號( - ),iconv從標準輸入讀取。
如果沒有提供from-encoding,則默認值來自當前的
語言環境的字符編碼。
ICONV(1) Linux User Manual ICONV(1)
NAME
iconv - convert text from one character encoding to another
SYNOPSIS
iconv [options] [-f from-encoding] [-t to-encoding] [inputfile]...
DESCRIPTION
The iconv program reads in text in one encoding and outputs the text in
another encoding. If no input files are given, or if it is given as a
dash (-), iconv reads from standard input. If no output file is given,
iconv writes to standard output.
If no from-encoding is given, the default is derived from the current
locale's character encoding. If no to-encoding is given, the default
is derived from the current locale's character encoding.
EXAMPLE
將文件從ISO big5字符編碼轉換為UTF-8:
$ iconv -f big5-t UTF-8 < input.txt > output.txt
下一個範例將UTF-8轉換為ASCII:
$ echo abc ß α € àḃç | iconv -f UTF-8 -t ASCII//TRANSLIT
abc ss ? EUR abc
整個目錄轉換
新建目錄twemail-utf8
進入來源目錄(big5)
find . -type f -exec bash -c 'iconv -f big5 -t utf-8 "{}" > ../twemail-utf8/"{}"' \;
透過PHP轉換
string iconv ( string $in_charset , string $out_charset , string $str )
<?php
$text = "This is the Euro symbol '€'.";
echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;
?>
add comment
( 297 views )
| 0 trackbacks
| permalink
| related link
| ( 3 / 203 )
Release
MD5 checkMd5Sum
Driver