Strange characters and encoding while using twitter API - php

I begun developing my own SIMPLE twitter client in my server (to bypass twitter.com blocking rule stablished by some dumbass at govt. office)
Please check this image so you can see the accented characters converted into weird symbol:
It is being developed with this class Twitter PHP class by Tijs Verkoyen
This is my heading code, which is utf-8. Can anyone point me to a fix?
<!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" />
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>

try using the utf8_encode() function with PHP

best is to avoid hassle if you could pass all your twitter texts(i.e. twitter API delivers JSON format too) using some sort of JSON format and pass those JSON into PHP 5 function
json_decode(jsonStr);
json_decode automatically converts to utf8 encoding which can save you from writing extra code for character encoding..

Related

My CKEditor and input field do not support Unicode

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.

In Google cloud, Language texts not displayed in proper way

I have a piece of code in html and php for my index.php. This page is used for users to register. The users inserts its details and the registration process works successfully. The user can insert its details written in every language, and all characters are recognized and displayed in the right format. That works fine in localhost in my laptop using xampp. When I uploading my code to google cloud, however a problem occurs. If the user register himself with text lets say in Russian language, then in my database text stored in a strange format like & upsilon ; etc Probably the problem here is that when I upload my code to google cloud, not all language formats are read in the proper way. Any ideas on how to fix this?
This is my code:
<?php
include 'init.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/main.css" type="text/css">
<title> My page </title>
</head>
<body>
----------here is the form where the user register
</body>
</html>
my problem is that when a user

ZF2 Mail UTF-8 & Outlook express

I am using ZF2 to send emails with UTF-8 encoding:
$message->setEncoding('UTF-8');
With such test content:
<!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" />
<title>Test</title>
</head>
<body bgcolor="#FFFFFF">
ĄŚĆÓłąóźćżźęĄŚĆÓłąóźćżźęĄŚĆÓłąóźćżźę
</body>
</html>
Everything is correct in modern browsers or email clients. Problem is that old OutlookExpress doesn't recognize this. Message is displayed with ISO.
What should I do to make it read properly?
I found solution. When sending html the part have its own encoding. Setting UTF-8 there makes OE read message correctly.
$html = new Mime\Part($text);
$html->type = Mime\Mime::TYPE_HTML;
$html->charset = 'utf-8';
I guess OutlookExpress is able to show UTF8. But I experienced a situation where a client had a setting to force ISO encoding instead of detection from e-mail. So check the settings of outlookExpress.
Another thing which I would do is to send email from gmail with UTF8 encoding and read it in this OutlookExpress.
- Is it showed corectly? If yes, then look on the source of the mail and check what's different from yours. If not, then problem is probably in the OutlookExpress setings.

How To Strip HTML Tags From JSON Response In Blackberry

I have a php script that returns a JSON response
that i used in android to load a listview.
I now want to achieve the same functionality in blackberry,
but am getting an error when it comes to parsing the JSON response.
The php script excerpt to echo the response is this :
<?php
$response=array();
include 'connect.php';
$cat=mysqli_real_escape_string($link,$_POST['category']);
------------
array_push($response["items"],$item);
echo $json_encode($response);
?>
and the response i get on the blackberry simulator is this :
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
{"items":[{"id":"1","item_name":"Sparkling Wine"}],"success":1}
This response gives an error when trying to parse the JSON response.
I will like a resonse in this format :
{"items":[{"id":"1","item_name":"Sparkling Wine"}],"success":1}
without the excess headers. I use exactly the same script on another machine, and it works for android development perfectly. The only difference is that i use XAMPP as my webserver, while on the current machine i use WAMP. I need to know if it is the WAMP server that is muddying up my response. Need help. Thanks.

Why php includes doesn´t processes accents right?

As explained here (PHP Include and accents (They show up as �)) php has a strange behavior processing the accents. My question is Why?
I mean: I have a simple utf-8 charset page. With 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>
<title>My Title</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<?php include ('file.php');?>
The included file just says: "Administración." It has no charset, just header tags (h2, h3...), and some links. Like this:
<h2>Administración</h2>
So, there is no charset conflict. Are not they supposed that the include files are just included?
The previous question was answered with some fix to the problem, but my question is Why PHP behaves this way?
to answer you new questions (from your comment):
How can I do the same thing in other
editors, how do I know the default
charset?
default-charset and charset for every single file can be set in almost every code-editor i know - where exactly depends on the editor. simply take a look into the manual/documentation of your editor for that.

Categories