944,111 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1208
  • PHP RSS
Nov 8th, 2009
0

how can i make a web page having both english and hindi character with php mysql

Expand Post »
How to handle UTF-8 characters in HTML, JavaScript, PHP and MySQL ...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mahakaal is offline Offline
6 posts
since Jul 2009
Nov 8th, 2009
1
Re: how can i make a web page having both english and hindi character with php mysql
Hey.

HTML:
html Syntax (Toggle Plain Text)
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf8">
  5. </head>
  6. <body />
  7. </html>

MySQL
mysql Syntax (Toggle Plain Text)
  1. -- When creating a table:
  2. CREATE TABLE `myTable`(
  3. -- <insert fields>
  4. )DEFAULT CHARSET=utf8;
  5.  
  6. -- Before querying the database.
  7. -- Note, this is usually not needed, but can be.
  8. SET NAMES 'utf8';

And as to PHP and Javascript...
You usually don't have to worry much about the character encoding in either of those. Just make sure you create the code files themselves as UTF-8 (without BOM) and you should be fine.
PHP strings are basically just byte arrays, so they don't differentiate between charsets, unless you attempt to manipulate them using the string functions, in which case they are treated as ISO. (Unless the function offers the ability to specify a charset.)

However, if PHP is giving you trouble, you can use utf8_encode to convert ISO characters over to UTF-8.
Also, if you use htmlentities or htmlspecialchars, make sure you set the third parameter correctly.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Nov 9th, 2009
0
Re: how can i make a web page having both english and hindi character with php mysql
nice info Atli... i guess it will prove helpful fr me someday

Click to Expand / Collapse  Quote originally posted by Atli ...
Hey.

HTML:
html Syntax (Toggle Plain Text)
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf8">
  5. </head>
  6. <body />
  7. </html>

MySQL
mysql Syntax (Toggle Plain Text)
  1. -- When creating a table:
  2. CREATE TABLE `myTable`(
  3. -- <insert fields>
  4. )DEFAULT CHARSET=utf8;
  5.  
  6. -- Before querying the database.
  7. -- Note, this is usually not needed, but can be.
  8. SET NAMES 'utf8';

And as to PHP and Javascript...
You usually don't have to worry much about the character encoding in either of those. Just make sure you create the code files themselves as UTF-8 (without BOM) and you should be fine.
PHP strings are basically just byte arrays, so they don't differentiate between charsets, unless you attempt to manipulate them using the string functions, in which case they are treated as ISO. (Unless the function offers the ability to specify a charset.)

However, if PHP is giving you trouble, you can use utf8_encode to convert ISO characters over to UTF-8.
Also, if you use htmlentities or htmlspecialchars, make sure you set the third parameter correctly.
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Forget Password in PHP
Next Thread in PHP Forum Timeline: require() all files in a directory structure





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC