當前位置:首頁 » 操作系統 » linuxiconv

linuxiconv

發布時間: 2022-03-08 13:17:56

linux iconv函數在哪個庫

1、下載libiconv函數庫ftp/pub/gnu/libiconv/libiconv-1/pub/gnu/libiconv/libiconv-1/manual/zh/function.mb-convert-encoding.php 做一個GBK To UTF-8 復制代碼 代碼如下: < ?php header("content-Type: text/html; charset=Utf-8"); echo mb_convert_encoding("你系我的友仔", "UTF-8", "GBK"); ?> 再來個GB2312 To Big5 復制代碼 代碼如下: < ?php header("content-Type: text/html; charset=big5"); echo mb_convert_encoding("你是我的朋友", "big5", "GB2312"); ?> 不過要使用上面的函數需要安裝但是需要先enable mbstring 擴展庫。 PHP中的另外一個函數iconv也是用來轉換字元串編碼的,與上函數功能相似。 下面還有一些詳細的例子: iconv — Convert string to requested character encoding (PHP 4 >= 4.0.5, PHP 5) mb_convert_encoding — Convert character encoding (PHP 4 >= 4.0.6, PHP 5) 用法: string mb_convert_encoding ( string str, string to_encoding [, mixed from_encoding] ) 需要先enable mbstring 擴展庫,在 php.ini里將; extension=php_mbstring.dll 前面的 ; 去掉 mb_convert_encoding 可以指定多種輸入編碼,它會根據內容自動識別,但是執行效率比iconv差太多; string iconv ( string in_charset, string out_charset, string str ) 注意:第二個參數,除了可以指定要轉化到的編碼以外,還可以增加兩個後綴://TRANSLIT 和 //IGNORE,其中 //TRANSLIT 會自動將不能直接轉化的字元變成一個或多個近似的字元,//IGNORE 會忽略掉不能轉化的字元,而默認效果是從第一個非法字元截斷。 Returns the converted string or FALSE on failure. 使用: 發現iconv在轉換字元」—」到gb2312時會出錯,如果沒有ignore參數,所有該字元後面的字元串都無法被保存。不管怎麼樣,這個」—」都無法轉換成功,無法輸出。 另外mb_convert_encoding沒有這個bug. 一般情況下用 iconv,只有當遇到無法確定原編碼是何種編碼,或者iconv轉化後無法正常顯示時才用mb_convert_encoding 函數. from_encoding is specified by character code name before conversion. it can be array or string - comma separated enumerated list. If it is not specified, the internal encoding will be used. /* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */ $str = mb_convert_encoding($str, "UCS-2LE」, "JIS, eucjp-win, sjis-win」); /* "auto」 is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS」 */ $str = mb_convert_encoding($str, "EUC-JP」, "auto」); 例子: 復制代碼 代碼如下: $content = iconv(」GBK」, "UTF-8", $content); $content = mb_convert_encoding($content, "UTF-8", "GBK」);

⑵ linux下的編碼轉化問題,函數iconv的使用

看起來你的代碼沒什麼問題啊:
#include <iconv.h>

size_t iconv(iconv_t cd,
char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);

你看函數原型, outbuf是一個 char **類型
在函數手冊中:
The iconv() function converts one multibyte character at a time, and for each character conversion it increments *inbuf and decrements
*inbytesleft by the number of converted input bytes, it increments *outbuf and decrements *outbytesleft by the number of converted
output bytes

也就是說,當你執行過iconv以後,*outbuf所指向的內存空間位置已經被改掉了, 所以你任何時候去讀*outbuf, 都是讀不到任何iconv後的數據的(都在*outbuf這個指針前面放著呢)。

所以你應該 預先備份outbuf的數據,
比如 char k[1000]; char *outb = k; 執行完iconv(t,&inb,&inl,&outb,&outl)以後,你去讀k數組就可以了。

⑶ Linux下除了iconv函數用著轉換編碼,還有哪些函數可以轉換

這個主要是碼表麻煩,幸好有現成的
http://hi..com/silyt/blog/item/a5a1672e183c8a554fc2261e.html

⑷ linux下編碼轉換問題,C語言實現,使用iconv函數族

1、iconv的含義是將一個抽象的符號的編碼進行轉換。
但是如果一個符號比如「個」,可能在BIG5的編碼中不存在(繁體字中不同)
GBK包含的是簡體字,BIG5包含的是繁體字,Unicode包含全部,
所以
GBK->Unicode,Big5-Unicode (總是OK)
Unicode->GBK (當裡面僅包含英文及簡體時OK)
Unicode->BIG5 (當裡面僅包含英文及繁體時OK)
GBK->Big5 (基本上不行,除非某些字沒有特別的簡體字)
GBK->Big5是漢字的簡繁轉換,不是編碼轉換,簡體字轉繁體字還有一個問題,一個簡體字可能是對應多個繁體字,這種很難轉換正確。繁體字轉換成簡體字相對難度低。

2、#include <iconv.h>
size_t iconv(iconv_t cd,
char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
函數原型, outbuf是一個 char **類型
在函數手冊中:
The iconv() function converts one multibyte character at a time, and for each character conversion it increments *inbuf and decrements
*inbytesleft by the number of converted input bytes, it increments *outbuf and decrements *outbytesleft by the number of converted
output bytes

⑸ linux下用iconv函數進行格式的轉換,運行時在iconv函數上總是退出程序,出錯,求解

檢查一下第四個參數。
size_t iconv (iconv_t cd,
const char* * inbuf, size_t * inbytesleft,
char* * outbuf, size_t * outbytesleft);
你是如何定義的,又是如何調用的?
參考的定義方法及調用方法:
char output[BUFSIZ], *outp = output;
iconv(cd, inbuf, &insize, &outp, &outsize);

⑹ Linux下iconv bus error該如何解決

bus error 是匯流排錯誤,這個錯誤一般是程序無法有效兼容當前 CPU 的工作而報錯。
這只能刪了這個軟體重新裝。

⑺ iconv 是不是linux標准庫

linux是操作系統,不存在標准庫概念。
如果說linux所使用的C語言,它的標准庫是啥?是glibc。
iconv是 glibc 中的內容。

關於 glibc
The GNU C Library is used as the C library in the GNU systems and most systems with the Linux kernel.

參考資料:
http://en.wikipedia.org/wiki/Iconv

All recent Linux distributions contain a free implementation of iconv() as part of the GNU C Library which is the C library for current Linux systems. To use it, the GNU glibc locales need to be installed, which are provided as a separate package (usually named glibc-locale) normally installed by default.

⑻ linux下libiconv庫怎麼用

權聲明:本文為博主原創文章,未經博主允許不得轉載。

Linux下libiconv庫的安裝和使用:

1.libiconv包的下載路徑

包的下載頁面http://www.gnu.org/software/libiconv/

2.編譯安裝libiconv庫

$tar zxvf libiconv-1.14.tar.gz

$cd libiconv-1.14

$ ./configure --prefix=/usr/local

$ make

$ make install

在/usr/local/lib/目錄下,拷備需要的庫文件libcharset.so.1, libiconv.so.2。

3.在makefiel文件中使用-liconv調用libiconv動態庫文件時,若出現「error while loading sharedlibraries: libiconv.so.2」錯誤,解決方法為:

$updatedb

$locate libiconv.so.2

發現該庫已經安裝,位置在/usr/local/lib/libiconv.so.2。既然已經安裝,為什麼提示找不到?繼續下一步排查。

$strace ./indexer 將列印出所有indexer 啟動時調用的文件及程序名稱,
在輸出的信息中,發現查找庫libiconv.so.2的路徑是/lib目錄和/usr/lib這兩個目錄。
好了,問題找到了,將/usr/local/lib下面該庫鏈接到/usr/lib下面即可
$ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2

$ldconfig

至此,解決該問題。

⑼ LINUX下板子需要用到iconv庫,在linux交叉編譯環境下,編譯通過沒有問題,但是拿到板子上

看下iconv用的是哪個庫,在configure的時候把他加上去就可以了
像gcc的話就./configure --gcc=/usr/local/gcc/bin
或者把一些lib庫的路徑放到你的PATH裡面

熱點內容
蘋果5忘記限制密碼怎麼辦 發布:2024-09-24 13:13:55 瀏覽:265
漆黑魅影怎麼配置 發布:2024-09-24 12:51:54 瀏覽:641
兄弟腳本官網 發布:2024-09-24 12:29:12 瀏覽:806
使命召喚4腳本 發布:2024-09-24 12:19:02 瀏覽:143
apriori演算法java 發布:2024-09-24 12:17:34 瀏覽:152
linux文件鎖 發布:2024-09-24 12:16:02 瀏覽:680
安防系統用存儲還是用磁碟陣列 發布:2024-09-24 12:15:58 瀏覽:738
紅石生存伺服器搭建 發布:2024-09-24 12:02:25 瀏覽:784
購物返利源碼 發布:2024-09-24 11:50:18 瀏覽:164
嵌入式資料庫java 發布:2024-09-24 11:09:13 瀏覽:831