当前位置:首页 » 操作系统 » 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里面

热点内容
centos给文件夹权限 发布:2024-09-24 15:14:15 浏览:289
shell脚本指定用户 发布:2024-09-24 15:00:03 浏览:257
如何给文件夹写保护 发布:2024-09-24 14:54:00 浏览:43
mysql查看数据库表结构 发布:2024-09-24 14:27:39 浏览:236
linuxvnc启动 发布:2024-09-24 14:10:50 浏览:219
pythondjango网站 发布:2024-09-24 14:01:09 浏览:96
ug编程入门 发布:2024-09-24 13:56:56 浏览:709
c语言合并字符串函数 发布:2024-09-24 13:55:36 浏览:112
运维过滤服务器的ip地址 发布:2024-09-24 13:52:26 浏览:92
苹果5忘记限制密码怎么办 发布:2024-09-24 13:13:55 浏览:268