3
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by venkat0904
1

Hey.

HTML:

<!DOCTYPE html>
<html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=utf8">
    </head>
    <body />
</html>

MySQL

-- When creating a table:
CREATE TABLE `myTable`(
  -- <insert fields>
)DEFAULT CHARSET=utf8;

-- Before querying the database.
-- Note, this is usually not needed, but can be.
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.

0

nice info Atli... i guess it will prove helpful fr me someday

Hey.

HTML:

<!DOCTYPE html>
<html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=utf8">
    </head>
    <body />
</html>

MySQL

-- When creating a table:
CREATE TABLE `myTable`(
  -- <insert fields>
)DEFAULT CHARSET=utf8;

-- Before querying the database.
-- Note, this is usually not needed, but can be.
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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.