Wordpress fonts not displaying properly - php

I'm working on a new Wordpress website, and it has both Sinhala and English characters, the charset of the website and the database is UTF-8. However although the English characters are displayed properly the Sinhala characters are displayed as question marks.
I can't seem to find an error, how can I fix it ?

First of all you can select a font file and font-face into your css file. You should write your text Unicode format.
#font-face {
font-family: myFirstFont;
src: url(sansation_light.woff);
}
div {
font-family: myFirstFont;
}

Just comment these two lines in wp-config.php and check.
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

If you are importing this data from another source, please make sure that the export script does the DB export with UTF8 character set. In my case this was the problem
if the database is mysql use the below line to export the source DB.
mysqldump --default-character-set=utf8 -r{export.sql} -u{uname} -p{pass} {db} -h{server}

Related

MySQL/php Charset madness: which one is correct?

I imported a list of name in mysql, directly from txt file to phpmyadmin, european names.
My html header is set to utf8, mysql is set to utf8.
now the names with accent like Contè, display a <?> instead of accents.
If i remove the meta ut8, I can see the accents correctly, but everything else breaks, for instance when i upload a file like Aleš.jpg the html spit out a unreadable filename..
i'm lost..
It smells like the text file was encoded in latin1 some other encoding.
Can you provide a hex dump of "Contè" as found in the file? We can help you recognize whether it is utf8 or not. http://mysql.rjweb.org/doc.php/charcoll#8_bit_encodings shows that è is hex E8 in latin1 or C3A8 in utf8.
Once the encoding is determined, the tag on the html page can be fixed to agree with it.

Unicode characters displaying weird in all browsers but Chrome

My unicode characters are displaying weird in all browsers but Chrome. Hereis my site- any idea why? I'm using the Typesplugin and just copy/pasting the uncode letters in.
Thanks for posting on StackOverflow. Try to create a custom wordpress page. Like so...
<?php
include('/wp_blog_header.php'); //change this to reflect the location of your wp_blog_header.php
get_header();
echo "Your CharSet is: ".bloginfo('charset');
get_footer();
?>
This will tell you what wordpress has your Character Set setting set to. If it's not UTF-8 change it to reflect that (it's the most compatible with each language).
Alternatively, you can also add this line to your wp-config.php
define('DB_CHARSET', 'utf8'); // force utf8
define('DB_COLLATE', 'utf8_general_ci'); // force collation
If I provided the best solution, please mark this as the answer to your issue :) Thanks again for posting.

How to implement tamil font for my website?

I have developed the website in codeigniter, now i want to add tamil fonts in my website .
Type the description in tamil, and add the description value into the description table desc colum and retrieve the desc values and display that tamil content to my website..
You can do it with CSS3!
Before the functionality didn't actually exist beyond having the font pre-installed. Tamil fonts are unicode and often are ttf files. So make sure you have the ttf file on your web-server in order to have it available for use.
<style>
#font-face
{
font-family: myTamilFont;
src: url(tamil_font.ttf);
}
div
{
font-family: myTamilFont;
}
</style>
This will not work IE8 and below
For more information: http://www.w3schools.com/css3/css3_fonts.asp
Similar question asked on StackOverflow: How to embed fonts in HTML?
Use meta tag char set utf8 for using tamil font...
for insert database you should use ..
mysql_query ("set character_set_results='utf8'");
Hope this will help you

How do I debug not working characters in PHP/HTML/MySQL?

I am building a webpage in HTML with PHP and MySQL and I ran into trouble with swedish characters ÅÄÖ when running page. They show up as � instead of Å/Ä/Ö.
I have set the charset to UTF-8 in both HTML meta-tag and via PHP:
<?php
header('Content-type: text/html; charset=UTF-8');
?>
<meta charset="UTF-8">
Also, MySQL runs utf8_general_ci collation on all tables.
All files should also be encoded and saved as UTF-8 without Unicode Signature (BOM) and no normalization form.
All this have worked flawless before, but today, nomather what I try I do end up with � instead of Å/Ä/Ö. Is there a good way to debug this and find the problem?
Is any of my steps unnecessary or have I forgotten anything?
What you need from deceze's article is the part regarding the SET NAMES:
mysql_set_charset('utf8', $connection); //not mysql_query("SET NAMES 'utf8'");
Just add that at the beginning of your php code, after the database connection was started
You may try save your php files in UTF-8 encoding. I assume the files are written in something else (possibly ISO-xxxx or ANSI)
To do that with Notepad++, select all the lines and copy to clipboard, change the coding to UTF-8 without BOM in encoding menu, then paste over everything and save.
Is this for only few records or all records with swedish characters?
You can change the page encoding manually in browser settings - this is how you test it: change it to latin1/iso-8854-1 to see if it displays these correctly that are wrong as utf-8.
Chances are someone is using browser that is not supporting utf8 or fiddled with the encoding manually.
Also make sure you db connection is utf8 too. (set names utf8;)

CKEditor charset

I updated my web app to use UTF-8 instead of ANSI.
I did the following measures to define charset:
mysql_set_charset("utf8"); // PHP
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> // HTML
utf8_general_ci // In MySQL
I also edited the CKEditor config to remove htmlentities because I need the correct character (i.e. é and not é) for MySQL fulltext search.
config.entities = false;
config.entities_latin = false;
In the database (phpMyAdmin view) and on normal text fields output (HTML, <input> or <textarea>), everything looks fine (I see é, not é, not é, yay).
However, CKEditor has some trouble with the encoding. See attached image for the same field taken from the database, displayed in a textarea, then in a textarea repalced by CKEditor:
This seems to be in the CKEditor JavaScript code (probably a fixed charset), but I can't find it in the config. Again, since the é displays correctly in normal HTML (real UTF-8 é, not é nor é), I'm quite sure it's not the PHP/MySQL query that's wrong (but I might be mistaken).
EDIT: This seems like a symptom of applying htmlentities, which by default is encoded in Latin-1, on UTF-8 text. There is either a possibility of using htmlspecialchars or to specify the charset ("utf-8"), but I don't know where to modify that in CKEditor.
This thread seems bit dated but answering it to help anyone looking for a response.
To allow CKEditor to process the character é as é and not é set the config for entities_latin to false, as below:
config.entities_latin = false;
Or, you may just want to set following options to false:
config.entities = false;
config.basicEntities = false;
It was my approach that was wrong, not CKEditor's. Was looking in the wrong file and missed the UTF-8 encoding on a htmlspecialchars.
You can also use in your database connection: $connection->query("SET NAMES 'utf8'");
And remember to set db, and/or table Collation to utf8... I prefer utf8_general_ci

Categories