标签: iconv

如何通过php中的iconv库获取支持的编码列表?

是否有可能像mcrypt库中的功能mcrypt_list_algorithms().是否有像函数一样的iconv_list_encodings?

php iconv

20
推荐指数
1
解决办法
2万
查看次数

将任何可转换的utf8字符音译为ascii等效字符

有没有什么好的解决方案以良好的方式进行这种音译?

我尝试过使用iconv(),但是非常烦人,而且它的行为并不像人们预期的那样.

  • 使用//TRANSLIT将尝试替换它可能的东西,将所有不可转换的东西留作"?"
  • 使用//IGNORE不会留下"?" 在文本中,但也不会音译,并且E_NOTICE当找到不可转换的字符时也会引发,所以你必须使用带有@ error suppressor的iconv
  • 使用//IGNORE//TRANSLIT(正如一些人在PHP论坛中建议的)实际上是相同的//IGNORE(在php版本5.3.2和5.3.13上自己尝试过)
  • 也使用//TRANSLIT//IGNORE与...相同//TRANSLIT

它还使用当前区域设置进行音译.

警告 - 许多文本和代码如下!

这里有些例子:

$text = 'Regular ascii text + ??žš? + äöüß + é???ë? + æø€ + $ + ¶ + @';
echo '<br />original: ' . $text;
echo '<br />regular: ' . iconv("UTF-8", "ASCII//TRANSLIT", $text);
//> regular: Regular ascii text + ????? + ???ss + ?????? + ae?EUR + $ + ? + …
Run Code Online (Sandbox Code Playgroud)

php ascii utf-8 transliteration iconv

20
推荐指数
2
解决办法
2万
查看次数

osx更改文件编码(iconv)递归

我知道我可以使用以下命令在OSX下转换单个文件编码:

iconv -f ISO-8859-1 -t UTF-8 myfilename.xxx > myfilename-utf8.xxx

我必须转换一堆具有特定扩展名的文件,所以我想将文件编码从ISO-8859-1转换为UTF-8,用于文件夹/ mydisk/myfolder中的所有*.ext文件

或许有人知道如何做到这一点的语法

谢谢

EKKE

macos shell encoding glob iconv

19
推荐指数
1
解决办法
2万
查看次数

iconv任何编码为UTF-8

我试图将iconv指向一个目录,所有文件都将转换为UTF-8,无论当前编码如何

我正在使用此脚本,但您必须指定要进行的编码.如何让它自动检测当前编码?

dir_iconv.sh

#!/bin/bash

ICONVBIN='/usr/bin/iconv' # path to iconv binary

if [ $# -lt 3 ]
then
    echo "$0 dir from_charset to_charset"
    exit
fi

for f in $1/*
do
    if test -f $f
    then
        echo -e "\nConverting $f"
        /bin/mv $f $f.old
        $ICONVBIN -f $2 -t $3 $f.old > $f
    else
        echo -e "\nSkipping $f - not a regular file";
    fi
done
Run Code Online (Sandbox Code Playgroud)

终点线

sudo convert/dir_iconv.sh convert/books CURRENT_ENCODING utf8
Run Code Online (Sandbox Code Playgroud)

linux ubuntu encoding utf-8 iconv

19
推荐指数
4
解决办法
4万
查看次数

在'require'中:没有要加载的文件 - iconv(LoadError)

    ?  expertiza git:(master) ? ruby -v
    ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0]
    ?  expertiza git:(master) ? rails -v
    Rails 2.3.14
    ?  expertiza git:(master) ? script/server
/Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/inflector.rb:3:in `require': no such file to load -- iconv (LoadError)
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/inflector.rb:3
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer/inflections.rb:1:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer/inflections.rb:1
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer.rb:2:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer.rb:2
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8:in `each'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support.rb:56:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support.rb:56
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.14/lib/commands/server.rb:1:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.14/lib/commands/server.rb:1
    from script/server:3:in `require'
Run Code Online (Sandbox Code Playgroud)

我试过安装

rvm pkg install readline
rvm pkg install iconv
rvm …
Run Code Online (Sandbox Code Playgroud)

ruby terminal ruby-on-rails iconv rvm

17
推荐指数
2
解决办法
3万
查看次数

在Twitter中的表情分析中的表情符号

如何处理/删除表情符号以便我可以对推文进行情感分析?

获取:sort.list(y)中的错误:输入无效

谢谢

这就是表情符号从twitter发送到r中的方式:

\xed??\xed?\u0083\xed??\xed??
\xed??\xed?\u008d\xed??\xed?\u0089 
Run Code Online (Sandbox Code Playgroud)

r text-mining iconv sentiment-analysis

17
推荐指数
1
解决办法
1万
查看次数

Mac OSX 上的 _libiconv 或 _iconv 未定义符号

在 Mac OSX 上从源代码编译某些包时,出现以下 iconv 错误:

Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
  "_iconv_close", referenced from:
  "_iconv_open", referenced from:
Run Code Online (Sandbox Code Playgroud)

或者我得到:

Undefined symbols for architecture x86_64:
"_libiconv", referenced from:
"_libiconv_open", referenced from:
"_libiconv_close", referenced from:
Run Code Online (Sandbox Code Playgroud)

为什么会发生这种情况,我该如何解决这种依赖性,或者更一般地说,弄清楚发生了什么以及如何解决它?

iconv libiconv

17
推荐指数
3
解决办法
5025
查看次数

libiconv和MacOS

我正在尝试在Mac OS X Lion中编译GCC 4.5.1.

我有libiconv的问题.首先,它抱怨的建筑x86_64的未定义的符号,其分别为:_iconv,_iconv_open和_iconv_close.我发现MacPorts版本的libiconv将这些重命名为:_libiconv,_libiconv_open和_libiconv_close.所以我链接到/ usr/lib中的Mac OS本机libiconv而不是/ opt/local/lib中的MacPorts库.

Undefined symbols for architecture x86_64:
"_iconv", referenced from:
  _convert_using_iconv in libcpp.a(charset.o)
  __nl_find_msg in libintl.a(dcigettext.o)
 (maybe you meant: __cpp_destroy_iconv, _cpp_init_iconv )
"_iconv_close", referenced from:
  __cpp_destroy_iconv in libcpp.a(charset.o)
  __cpp_convert_input in libcpp.a(charset.o)
  __nl_free_domain_conv in libintl.a(loadmsgcat.o)
"_iconv_open", referenced from:
  _init_iconv_desc in libcpp.a(charset.o)
  __nl_init_domain_conv in libintl.a(loadmsgcat.o)
Run Code Online (Sandbox Code Playgroud)

但是,在这之后,我尝试从头开始重建它(清理和所有内容),但后来却抱怨未定义符号的不同点,但这次是_libiconv,_libiconv_open和_libiconv_close.

Undefined symbols for architecture x86_64:
  "_libiconv", referenced from:
    _identifier_to_locale in libbackend.a(pretty-print.o)
  "_libiconv_close", referenced from:
    _identifier_to_locale in libbackend.a(pretty-print.o)
  "_libiconv_open", referenced from:
    _identifier_to_locale in libbackend.a(pretty-print.o)
Run Code Online (Sandbox Code Playgroud)

我有什么想法可以解决这个问题吗?我找到了从MacPorts卸载libiconv的一些解决方案,但我不想这样做,因为我有很多端口取决于它.

gcc iconv libiconv osx-lion

16
推荐指数
2
解决办法
1万
查看次数

为什么iconv无法从utf-8转换为iso-8859-1

我的系统是SUSE Linux Enterprise Server 11.

我正在尝试将数据从utf-8格式转换为iso使用"iconv"

$>file test.utf8
test.utf8: UTF-8 Unicode text, with very long lines
$>
$>file -i test.utf8
test.utf8: text/plain charset=utf-8
$>
$>iconv -f UTF-8 -t ISO-8859-1 test.utf8 > test.iso

iconv: test.utf8:20:105: cannot convert
Run Code Online (Sandbox Code Playgroud)

你能帮我解释一下吗?谢谢.

linux iso suse utf-8 iconv

16
推荐指数
3
解决办法
3万
查看次数

iconv UTF-8 // IGNORE仍会产生"非法字符"错误

$string = iconv("UTF-8", "UTF-8//IGNORE", $string);
Run Code Online (Sandbox Code Playgroud)

我认为这段代码会删除无效的UTF-8字符,但它会产生[E_NOTICE] "iconv(): Detected an illegal character in input string".我错过了什么,如何从非法字符中正确地删除字符串?

php utf-8 iconv

14
推荐指数
1
解决办法
2万
查看次数