My CKEditor and input field do not support Unicode - php

I am using CKEditor, i want to use Unicode and insert in database.
I copy the language and paste in CKEditor or input text and try to insert in database phpmyadmin. But I cannot get the desired output.
How to make my php website Unicode supportive. I am using HTML4 and i need to change my heading.
Here is my HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="ISO-8859-1">

I m using phpmyadmin, and i change collations and set it to utf8_general_ci.
And That solve my problem.

Related

Mail template encoding suddenly wrong. Only rewrite manually works it seems. Some tips, knowledge?

I have a problem with our E-Mail templates.
They worked fine until 2-3 days ago i have no idea what happened.
They should be utf8 encoded and get shown correctly in PHP Storm they look something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
....
}
</style
</head>
<body>
<center>Content with unique characters like ěäüß</center>
</body>
</html>
But in the Email the output is completely rubbish:
Vaše zakázka etc.
I use the output buffer to get the template content and send it with PHPMailer.
There is no encoding anywhere but shouldn't be needed.
I tried utf8-encode/decode etc. It makes everything only worse.
The only thing that worked is to use tools like this http://www.percederberg.net/tools/text_converter.html
to convert the plain text into utf-8 and then the code looks like rubbish like in the mail output, but then you can manually correct every character.. that worked for some templates like in german with some äüß.... but in the Czech template you have to rewrite every single character.
Is there something that i missed? Something that i could try?
I used htmlentities() on the text parts of the templates and worked quite decent!
Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
....
}
</style
</head>
<body>
<center><?php echo htmlentities("Content with unique characters like ěäüß"); ?></center>
</body>
Hope this helps someone!

Character encoding not declared in html document

I have a file that I am getting a very weird error on. The error is:
The character encoding of the HTML document was not declared.
The document will render with garbled text in some browser configurations if
the document contains characters from outside the US-ASCII range.
The character encoding of the page must to be declared in the document or
in the transfer protocol.
the file this comes from is (indexmws.php):
session_start();
if(!isset($_SESSION['validUser']) || $_SESSION['validUser'] !== true){
header('Location: loginmws.php');
}
include_once('db.php');
include_once('amazonmws.php');
include_once('decidemws.php');
include_once('author.php');
include_once('amazonPricingMWS.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Decision Maker</title>
This is an exact duplicate of a file that does not throw the error (index.php)with the exception of adding amazonPricingMWS.php and redirecting to pages with mws.php in the title:
session_start();
if(!isset($_SESSION['validUser']) || $_SESSION['validUser'] !== true){
header('Location: login.php');
}
include_once('db.php');
include_once('amazon.php');
include_once('decide.php');
include_once('author.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Decision Maker</title>
can anyone explain to me why I am getting this error in indexmws.php?
The error is coming because the browsers expect the encoding format in the first 1024 bytes of the file. It may be the case that there is some content being outputted by the included files in the first case.
The browsers now buffer the first 1024 bytes of the file to check for the character encoding. If the encoding description is not encountered in the first 1024 bytes, this warning is displayed.
In your case, you can use a php header for specifying the content type before the other files are included:
header('Content-type: text/html; charset=utf-8');
For more information, read this:
http://gtmetrix.com/specify-a-character-set-early.html
I had similar problem But teh exact reason behind this was that I missed following to add
<meta content="utf-8" http-equiv="encoding">
in head tag after
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">

Using regional language in php/html

I am working on a php based site where some texts are greek and some are english. Greek texts are not showing correctly. The file is saved in UTF-8. Is there anything special to do in the header of the html page to show the greek text correctly? My header is like -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Also when I submit a form containing greek text, I am using -
$firstname = mysql_real_escape_string($_POST['firstname']);
Is this okay to use "mysql_real_escape_string" here?
Try the following:
Set the collation of your database/ tables/ rows to UTF-8. UTF8_general_ci should do.
Set the connection between MySQL and PHP to UTF-8. (By executing the query SET NAMES 'utf8' after connecting or by setting the default connection encoding).
Try sending the content-type header with PHP: header("Content-Type: text/html; charset=utf-8");.

Byte Order Mark problem

I am having problem with byte order mark at the top of my php file. It is like - . For this there is an php warning is showing. I have removed the text twice. but it keeps coming. My file starts like this -
<?php include('PL/header.php'); ?>
Where 'header.php' is like this-
<?php require_once("BLL/index_isNotLoggedIn_bll.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
How can I solve this?
Your IDE is probably inserting the BOM whenever you save the file. You have to configure it to save as UTF-8 without the byte order mark.
How you do this depends on your IDE, check Google if needed.

Troubleshooting åäö to åäö

The problem:
An input of åäö in insert åäö in db. The file is in UTF-8 without BOM and comment in the table has utf8_general_ci coallition.
The code:
<?php
if($_POST['comment']!=''){
$comment=addcslashes($_POST['comment'], "\x00\n\r\'\x1a\x3c\x3e\x25");
if($kommentar!=''){
mysql_query("INSERT INTO comments (comment) VALUES ('$comment')") or die(mysql_error());
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="sv">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
//Form
</body>
Background:
Earlier I performed htmlentities on the $_POST['comment']; before inserting to db, and outputted directly, which worked fine. Then I wanted to go best practise and input raw data (just cleaning) and o htmlentities (or similar) on output. But then I discovered that e.g. åäö is not inputted as åäö but as åäö. Heeeelp :)
You probably need to set the connection's collation to UTF-8, which is iso-8859-1 by default.
Try
mysql_set_charset("utf8");
after connecting to the database.

Categories