mb-convert-encoding

Convert html entities to UTF-8, but keep existing UTF-8

风流意气都作罢 提交于 2021-02-10 11:45:31
问题 I want to convert html entities to UTF-8, but mb_convert_encoding destroys already UTF-8 encoded characters. Whats the correct way? $text = "äöü ä ö ü ß"; var_dump(mb_convert_encoding($text, 'UTF-8', 'HTML-ENTITIES')); // string(24) "äöü ä ö ü ß" 回答1: mb_convert_encoding() isn't the correct function for what you're trying to achieve: you should really be using html_entity_decode() instead, because it will only convert the actual html entities to UTF-8, and won't affect the existing UTF-8

Convert html entities to UTF-8, but keep existing UTF-8

旧时模样 提交于 2021-02-10 11:45:11
问题 I want to convert html entities to UTF-8, but mb_convert_encoding destroys already UTF-8 encoded characters. Whats the correct way? $text = "äöü ä ö ü ß"; var_dump(mb_convert_encoding($text, 'UTF-8', 'HTML-ENTITIES')); // string(24) "äöü ä ö ü ß" 回答1: mb_convert_encoding() isn't the correct function for what you're trying to achieve: you should really be using html_entity_decode() instead, because it will only convert the actual html entities to UTF-8, and won't affect the existing UTF-8

why do i have to use mb_convert_encoding($name,'ISO-8859-15','utf-8') to get accented chars to display?

邮差的信 提交于 2020-01-16 11:20:11
问题 the data im working with here is off of a page that uses utf8 encoding i've set my database and fields to use utf8_general_ci now for whatever reason, i have to use the following code on the variable in order to have it display accented characters correctly in the database: mb_convert_encoding($name,'ISO-8859-15','utf-8'); this makes no sense to me. why do i have to convert it to ISO-8859-15 when phpmyadmin is in utf8, the data is in utf8, and the database and table fields are in utf8? 回答1:

why do I need mb_convert_encoding to show the correct characters

梦想的初衷 提交于 2019-12-25 00:42:50
问题 my website have charset=UTF-8, and mysql DATABASE is also set to be UTF-8 encoding. my problem is that when I retrieve text from mysql to the website, i need to use php function mb_convert_encoding(@db_field,'utf-8','iso-8859-1') to show the text properly. it looks like that system think mysql DB is in iso-8859-1. 回答1: Run this right after you connect to the database: mysqli_query("SET NAMES utf8"); /* or mysql_query */ It is not enough to set the collation of the table to UTF-8, you also

Why does mb_convert_encoding fail? [closed]

淺唱寂寞╮ 提交于 2019-12-13 10:02:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Why does <?php echo "HELLO WORLD 1"; // shows error_reporting(E_ALL); echo "HELLO WORLD 2"; // shows print_r(mb_list_encodings()); // does not show echo "HELLO WORLD 3"; // does not show $result = mb_convert_encoding("apple", 'UTF-8'); echo "HELLO WORLD 4"; // does not show; echo $result; // does not show; // no

How can I convert “Western (Mac OS Roman)” formatted text to UTF-8 with PHP?

Deadly 提交于 2019-12-01 00:42:29
问题 I have files being exported by Excel for Mac 2011 VBA in Western (Mac OS Roman) as shown here: I haven't been successful in getting Excel for Mac VBA to export directly to UTF-8 so I want to convert these files with PHP before I save them to MySQL, I am using this command: $dataset[$k] = mb_convert_encoding($line, 'ASCII', 'UTF-8'); //not correctly converted $dataset[$k] = mb_convert_encoding($line, 'ISO-8859-8', 'UTF-8'); //not correctly converted $dataset[$k] = mb_convert_encoding($line,

How to keep the Chinese or other foreign language as they are instead of converting them into codes?

耗尽温柔 提交于 2019-11-27 16:14:29
DOMDocument seems to convert Chinese characters into codes, for instance, 你的乱发 will become ä½ çš„ä¹±å‘ How can I keep the Chinese or other foreign language as they are instead of converting them into codes? Below is my simple test, $dom = new DOMDocument(); $dom->loadHTML($html); If I add this below before loadHTML(), $html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8"); I get, 你的乱发 Even though the coverted codes will be displayed as Chinese characters, 你的乱发 still are not 你的乱发 what I am after.... DOMDocument seems to convert Chinese characters into codes [...]. How can I keep the

How to keep the Chinese or other foreign language as they are instead of converting them into codes?

旧时模样 提交于 2019-11-26 22:26:49
问题 DOMDocument seems to convert Chinese characters into codes, for instance, 你的乱发 will become ä½ çš„ä¹±å‘ How can I keep the Chinese or other foreign language as they are instead of converting them into codes? Below is my simple test, $dom = new DOMDocument(); $dom->loadHTML($html); If I add this below before loadHTML(), $html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8"); I get, 你的乱发 Even though the coverted codes will be displayed as Chinese characters, 你的乱发 still are not 你的乱发 what I