Random Question Mark Icons In WordPress Text - php

I am re-designing a WordPress site, and I imported all of the many thousand articles and noticed all of these little icons showing up randomly in the text. Sometimes it takes up 1 character, sometimes a whole sentence.
They also show up in the source the same way: �����
Tried different themes, as well as TypeKit/Google Fonts and am getting the same result.
Any ideas? langAttribute issue?

Oh man. Rookie move.
Issue was my wp-config file.
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
Once I added that I was good to go.

For those of you that are still wondering how to do that.
I have tried all the above and as nothing of that worked for me, I have found the following solution:
As my sql file was with latin1 encoding, I added the following lines to my wp-config.php file:
define('DB_CHARSET', 'latin1');
define('DB_COLLATE', 'latin1_swedish_ci');
AFTER that I imported the database and the issue was resolved.
So, just change the DB define values in your wp-config file to the ones that your database requires and then import the database. ^^

Related

fix WordPress custom menu character encoding

The problem is only with custom menus. When I create a new menu and I use non latin letters in menu name such as Arabic menu name or french name with characters such as "é" then it displays bogus characters such as "Municipalitéé" instead of "Municipalité"
The weird thing is that there are no issues if I add a new PAGE or POST through the wordpress CMS. This issue only happens when adding a new menu.
the entries are being saved wrong in the dabatase too (i checked the mysql database with phpmyadmin, and I saw that the values there have weird characters too).
So I believe this has to do with the database connection but however I do use the following code to specify the CHARSET in wp-config.php which contains the connection string to the database:
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
I have been fighting with this problem over the last 24 hours. Appreciate any help
It's not weird at all. wp_editor adds auto html entities. so your accents and such are converted to html entities, thus displayed properly. Menus are a different story, and are saved as is. with enconding being an issue, some installs may have difficulties as yours. try commenting out these 2 lines from the wp_config.php file
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
if this does not succeed, validate your database's character encoding. (simple trick if you have phpmyadmin is to manually insert those characters and validate they are saved properly.
let me know if you still have issues after this!
step 2: (edit 1)
uncomment lines from step 1, and make sure Settings->Reading->Encoding for Pages and Feeds is set to utf-8. make sure your set/collation for your mysql database is set to
UTF-8/utf8_general_ci
if not, convert all tables. a plugin used to exist for this but i haven't used it in ages and it seems to be unmaintained for an equal period of time... though slight modifications to the routines to make sure data structure is well represented would take less time than manually doing this.
https://wordpress.org/plugins/utf-8-db-converter/
let me know if step 2 fails.
to manually alter tables,
Change tables:
ALTER TABLE $table DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
Change columns:
ALTER TABLE $table CHANGE $field_name $field_name $field_type CHARACTER SET utf8 COLLATE utf8_general_ci
but as stated., it,s probably simpler to just use the plugin (modify it to suit new wordpress data structure, but then again, i believe it will take you less time than manually going through all existing fields in all existing tables. Changing database default encoding will only affect new tables and new columns
edit 3: issue was solved by using
define('DB_COLLATE', 'utf8_general_ci');
in the wp_config.php file. (troubleshooting happened in chat)

Support Special Characters in WordPress

I recently figure out the problem of supporting special characters in post or plugin.
I find this problem when i try to add the latin word it display ? as output. I googled a lot to conclude the problem has in
/** Database Charset to use in creating database tables. */
//define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
//define('DB_COLLATE', '');
So I just commented this and checked it working. ŠĐĆČŽ When i again undo the comment it returns ? mark.
Which is the best way inorder to support special characters in wordpress post or page or plugin.
Thanks.

UTF8 lithuanian characters unrecognized in MySQL database

I have well known but quite difficult to sort out problem here. And yes I was searching on forum but those threads are old enough so I decided to create new post.
So I built a website using WP and included html FORM in one page. When user fills the form (in his/her language) the values of the fields' go into MySQL database table reg_form.
Everything works, the values are saved, BUT some characters (specific in that language) are not recognized. I tried a lot of different methods to solve this, but nothing can help.
The strangest thing is that if you look at WordPress tables you can find those specific characters are recognizable but not in reg_form table which I created.
I was trying to solve this problem and finally I decided to approach in somehow ridiculous way. I created NEW database, new tables, installed new wordpress, created new form etc.
That‘s what I was doing:
I used this suggestion first:
http://tympanus.net/codrops/2009/08/31/solving-php-mysql-utf-8-issues/
Yes, my files are saved using UTF8 encoding (without BOM). Yes, meta tags are ok. Yes, the FORM uses accept-charset='UTF-8'. Yes, all tables in database use UTF8. Yes, server, database and tables collation is the same “utf8_general_ci”.
Then I tried to insert in my code this:
$conn = mysql_connect($server, $username, $password);
mysql_set_charset("UTF8", $conn);
Then I tried this suggestion
link here: akrabat.com/php/utf8-php-and-mysql/
Then I tried to set Apache's AddDefaultCharset in .htaccess file using this link here: httpd.apache.org/docs/2.0/mod/core.html#AddDefaultCharset
BUT… still the problem remains. I can’t see those specific characters properly – only weird hieroglyphic.
The problem you face has to do with a little specific detail in database character encoding settings and Wordpress.
While Wordpress has a general character encoding setting that normally takes care about database tables as well, it does not care about the default character encoding setting of the database those tables are in.
So when your plugin/code adds a database table your own, you need to take care about the encoding settings as well - because by default they will be the database default you create the table in, which most likely is latin-1 which does not work well for your language.
To set the default character set for the database (replace "wpdb" with your database name if it varies):
ALTER DATABASE wpdb CHARACTER SET utf8 COLLATE utf8_general_ci;
To change the character set for your existing table *"reg_form"*:
ALTER TABLE reg_form CONVERT TO CHARACTER SET charset_name;
Note: Backup your database first.
HOLLY SHIT!! FINALLY! : ))))))))
The problem was that I was using mysqli_ queries. Now I tried to change to mysql_ (notice the change!) queries and it worked!! Two weeks of haaaaard working and researches... Phew!
Now who can explain me properly the reasons of this phenomena? : ))

remove weird characters

I have imported the wordpress database and full source and implemented in my local server. I started working on it and i have also updated the wordpress version and also the plugins.
now the problem is that there are weird characters coming in my posts. such as ’ instead of '.
So now shall i remove this from everywhere now. i have lots of posts and i dont want to do laborious work. can we have fire some query on wordpress database and remove this character..
Try to change the database collation to UTF-8-GENERAL
charset in MySQL

Encoding problem in phpMyAdmin. Specifically with records containing russian text

I'm making small module/plugin for my future CMS/Framework. I wanted it from begining to be with multi-language support.
I set my new database to utf8_unicode_ci (I read that it is more accurate, then utf8_general_ci)
Set my files to UTF-8 without BOM
Every page has in head Content-Type: text/html; charset=utf8
When I register new user new record is added to user table. I tried to register user with russian nickname. When I inserted it to form it was fine. Added record to table. Signed in and showed greetings fine in russian too. But when I looked at the record in table the nickname was some gibberish characters. I tried all encodings in browser. Nothing helped.
UPD: I even tried to view data with SQLyog. Shows same as phpMyAdmin.
Small screenshot of what I mean alt text http://s43.radikal.ru/i101/1006/a9/f458f64a9918.png
Could anyone explain to me, what might be the problem?
Here's an earlier answer of mine about the same problem, try that: How to display a mysql table data in another language properly in php
Every page has in head Content-Type: text/html; charset=utf8
is it meta tag or HTTP header? must be a latter one.
and you have to run SET NAMES utf8 query every time you connect to the database in your PHP scripts

Categories