iconv

Call to undefined function Symfony\\Polyfill\\Mbstring\\iconv_strlen()

旧城冷巷雨未停 提交于 2019-12-03 05:57:12
My project works fine on localhost but not working online and this is the error: Fatal error: Call to undefined function Symfony\Polyfill\Mbstring\iconv_strlen() in /home/stram/public_html/vendor/symfony/polyfill-mbstring/Mbstring.php on line 338 I googled it and I found that I need to install the PHP extension iconv . The problem that I'm using a VPS and when I went to the list of available PHP extensions I didn't found this extension ! Thnx in advance. Symfony provides an iconv-polyfill for cases like that. Just add it as requirement to your project, and you should be fine: composer require

iconv 中文截断问题的解决方法

*爱你&永不变心* 提交于 2019-12-03 05:22:37
iconv 中文截断问题的解决方法 今天做了一个采集程序,原理很简单,使用curl方法把对方页面的html获取分析,然后正则提取需要的数据并保存在数据库。 由于对方页面是GB2312编码,而本地使用的是UTF-8编码。因此在采集后需要进行编码转换。 使用了 iconv 方法进行编码转换 [php] view plain copy iconv — 字符串按要求的字符编码来转换 string iconv ( string $in_charset , string $out_charset , string $str ) 将字符串 str 从 in_charset 转换编码到 out_charset 。 转换的方法很简单,直接使用iconv方法就可以了 [php] view plain copy <?php $content = iconv( 'GB2312' , 'UTF-8' , $content ); // $content为采集到的内容 ?> 试验了几个页面,都能正常采集。但在之后的采集中,有几个页面采集不完整。 一开始考虑是否正则有错,检查后排除此问题。经过排查,发现经过iconv转码后的内容比采集的内容少了一大段。 查看apache log,看到提示: Notice: iconv(): Detected an illegal character in input string

Converting UTF8 to ANSI with Ruby

痞子三分冷 提交于 2019-12-03 02:06:16
I have a Ruby script that generates a UTF8 CSV file remotely in a Linux machine and then transfers the file to a Windows machine thru SFTP. I then need to open this file with Excel, but Excel doesn't get UTF8, so I always need to open the file in a text editor that has the capability to convert UTF8 to ANSI. I would love to do this programmatically using Ruby and avoid the manual conversion step. What's the easiest way to do it? PS: I tried using iconv but had no success. ascii_str = yourUTF8text.unpack("U*").map{|c|c.chr}.join assuming that your text really does fit in the ascii character set

Ruby 2.0 iconv replacement

匿名 (未验证) 提交于 2019-12-03 02:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I don't know Ruby but want to run an script where: D:/Heather/Ruby/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- iconv (LoadError) it works somehow if I comment iconv code but it will be much better if I can recode this part: return Iconv.iconv('UTF-8//IGNORE', 'UTF-8', (s + ' ') ).first[0..-2] without iconv . Maybe I can use String#encode here somehow? 回答1: Iconv was deprecated (removed) in 1.9.3. You can still install it. Reference Material if you unsure: https://rvm.io/packages/iconv/ However

FreeTDS error connecting to SQL Server 2014

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have tried all the version available from 4.2 until 7.2, it seems to me all the versions I've tried are invalid. Looking at the errors logs and based on the Choosing TDS protocol , is SQL server 2014 supported? Brief error: Error 20017 (severity 9): Unexpected EOF from the server OS error 115, "Operation now in progress" Error 20002 (severity 9): Adaptive Server connection failed Looking at the log dumped by tsql: log.c:196:Starting log file for FreeTDS 0.91 on 2016-04-05 15:35:48 with debug flags 0x4fff. util.c:331:tdserror(0x18ec140,

Equivalent of Iconv.conv(“UTF-8//IGNORE”,…) in Ruby 1.9.X?

亡梦爱人 提交于 2019-12-02 23:30:24
I'm reading data from a remote source, and occassionally get some characters in another encoding. They're not important. I'd like to get get a "best guess" utf-8 string, and ignore the invalid data. Main goal is to get a string I can use, and not run into errors such as: Encoding::UndefinedConversionError: "\xFF" from ASCII-8BIT to UTF-8: invalid byte sequence in utf-8 I thought this was it: string.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?") will replace all knowns with '?'. To ignore all unknowns, :replace => '' : string.encode("UTF-8", :invalid => :replace,

PHP将表格导出为EXCEL格式

匿名 (未验证) 提交于 2019-12-02 22:11:45
话不多说上干活 public function downloadMatchDataAction() { // 要下载的信息 $user = new UserModel(); $sql = "SELECT id,name,age,sex ORDER BY age DESC LIMIT 0,100"; $list = $user->query($sql);//这里可以理解为查出来的二维数组 $th = ['编号','姓名','年龄','性别']; $datas = array();//定义空数组,用来装自己想要的数据格式 foreach($list as $key => $val){ $datas[$key][] = $val["id"]; $datas[$key][] = $val["name"]; $datas[$key][] = $val["age"]; $datas[$key][] = $val["sex"]; } //解释一下这个循环,$datas为二维数组,$key为$list的键,将$list里面的键变为$datas里面的键最后再给这个键附上我刚才查询的值 $this->outCsvTableAction('match',$th,$datas);//这里注意,指的是调用累内该方法 exit;//我这里我选择了退出因为导出并下载我已经完成了,做完以后还需要做记录请自行修改。

linux iconv文件编码转换

匿名 (未验证) 提交于 2019-12-02 21:56:30
linux系统里提供的文件转化编码的命令iconv,例如: iconv -t utf-8 -f gb2312 -c test.xml > text_UTF8.xml 1 -f 源编码 -t 目标编码 -c 忽略无法转换的字符 如果想批量转换,只需要执行如下两行命令即可: find folder -type d -exec mkdir -p utf/{} \; find floder -type f -exec iconv -f GB2312 -t UTF-8 {} -o utf/{} \; 1 2 这两行命令将folder目录下的文件由GB2312编码转换为UTF-8编码,目录结构不变,转码后的文件保存在utf/folder目录下。 来源:博客园 作者: mingzhang 链接:https://www.cnblogs.com/mingzhang/p/11653170.html

ISO-8859-1 Character truncates text inserting into utf-8 mysql column

橙三吉。 提交于 2019-12-02 18:10:17
问题 So I have a weird truncate issue! Can't find a specific answer on this. So basically there's an issue with an apparent ISO character ½ that truncates the rest of the text upon insertion into a column with UTF-8 specified. Lets say that my string is: "You need to add ½ cup of water." MySQL will truncate that to "You need to add" if I: print iconv("ISO-8859-1", "UTF-8//IGNORE", $text); Then it outputs: ½ O_o OK that doesn't work because I need the 1/2 by itself. If I go to phpMyAdmin and copy

PHP之iconv

纵然是瞬间 提交于 2019-12-02 15:06:09
使用iconv之前, 先了解一下utf-8编码和Unicode字符集: https://blog.csdn.net/zhusongziye/article/details/84261211 再了解一下gbk 来源: https://www.cnblogs.com/bneglect/p/11751462.html