I make a simple PhP program
<?php
echo $_GET['ID'];
?>
Then I call
http://localhost/testGetID/?ID=%E6%AD%A4%E5%8E%9F%E7%90%86%E6%98%AF%E5%9C%A8
This is what I got:
æ¤åŽŸç†æ˜¯åœ¨
What should I do so I show up actual chinese characters? The chinese characters will be ID for my databases by the way.
add this line to your <head></head> section <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
use urldecode() or mb_convert_encoding() function
encode the ID with base64_encode() and then decode it with base64_decode()
Can you try this?
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Test page</title>
</head>
Your php code/chinese characters go here.
<body>
</body>
</html>
Related
In my index.php I replaced
<div class="site_content"> ... </div>
with
<?php include ("site_content.php"); ?>
whilst all contents of the upper were copy&pasted into site_content.php.
The content now shows strange characters and the german encoding and charset (UTF-8) are not recognized any more. Before the change the encoding worked fine. The header of the index.php looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<title>...some title.... </title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<meta name="description" content=" ...some desc ...."/>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<?php include ("parts_index/site_content.php"); ?>
</body>
</html>
How can I solve this?
I've solved it.
The answer is very simple. The included php file was ANSI while my index.php was of course utf-8. When I converted the included file (site_content.php) to utf-8 no BOM it solved my problem! Thank you anyway for your time!
OZ
Currently I created simple website using include system
header.php - contains first part of HTML page (Head, meta tags, JS codes ... etc )
page.php - contains simple php code
page content
My main problem with arabic language
I have to put
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
in page.php, footer.php between <head> tags otherwise the arabic will not support correctly.
This prevents page validation because of these tags.
Is there any method to avoid this problem ?
Thanks
// Send a raw HTTP header
header ('Content-Type: text/html; charset=UTF-8');
// Declare encoding META tag, it causes browser to load the UTF-8 charset
// before displaying the page.
echo '<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />';
// Right to Left issue
echo '<body dir="rtl">';
Encode the arabic string into UTF-8 using a tool like this. (No need to change any settings - that link has the the correct settings you need).
Then use utf8_decode() to decode the string back.
Example:
<?php echo utf8_decode('your_encoded_string_goes_here'); ?>
Apart from all of the answers... Make sure your (HTML/PHP) files are saved with the right encoding utf-8
All you need is to put this
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
in a file that you include/include_once in your pages
EDIT. example:
header.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>my title in العربية</title>
</head>
<body>
mypage.php
<?php
include_once 'header.html';
?>
<p>
العربية
</p>
<?php
include 'foot.html';
?>
foot.html
<div>my footer</div>
</body>
</html>
1- Put this
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
2- You should also save the documents in UTF-8 not ANSI
Your headers should appear as the following:
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="utf-8">
</head>
<body>
Save your document as utf-8
I am Copying Hindi Words From Google Translator and Pasting it in my php page. In editor It is Correctly displaying But at Browser it is showing "???/" Marks. I have included charset"utf-8" in header also.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="hi">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<span>मैं एक अच्छा प्रोग्रामर हूँ</span>
</body>
</html>
Copy this and Save this in one html file..and try to run..it'll work..
can you please provide some help, this is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="wrapper">
<div id="container">
<?php
$var = utf8_encode("nađžćča slovaćč");
echo utf8_decode($var);
?>
</div>
</div>
</body>
</html>
I did try several things: removing utf8_encode / decode, putting header () in php code, but none of this worked, so can you please tell me where am I doing it wrong, thx!
You do not need to encode/decode data. Simply, you may save file using UTF-8 encoding.
You may get rid of this attribute lang="en". For me , I tried in different browsers and it works well
No need to encode or decode data.
test.php - Using regular IDE(phpDesigner7)
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
echo "بوغاليا";
?>
</body>
</html>
output : ???????
test.html - Using regular IDE(phpDesigner7)
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
بوغاليا
</body>
</html>
output : ???????
test.html - Using Arabic Pad
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
بوغاليا
</body>
</html>
output : بوغاليا
hello.php - Using Arabic Pad
<?php
echo "Hello";
?>
output : Nothing
I am running a local WAMP(PHP 5.3). From this.
I have tried saving these pages with : charset=utf-8 as well on both the programs with no luck.
I know for fact that my IDE can't handle special characters and the other program that Can handle special characters can write workable HTML but if PHP files are written in it, It will not work. I know this is an encoding issue(in the IDE and while displaying the pages).
How does one go about displaying special characters with PHP code, I have large chunks of this arabic text that needs to be displayed.
Do you know how is this done?
Thanks! :)
Why are you setting your charset to iso-8859-1? That's Latin-1. You can't render non-Latin characters in Latin-1.
Try using UTF-8 instead.