TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-10-2009, 10:01 AM   #1 (permalink)
The Wanderer
 
Join Date: Dec 2008
Posts: 15
Thanks: 2
ChrisR is on a distinguished road
Default UTF8 support

I want to know how can i make a script have full utf8 support? do i just use utf8_encode()/utf8_decode() ???
ChrisR is offline  
Reply With Quote
Old 06-10-2009, 10:35 PM   #2 (permalink)
The Acquainted
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 158
Thanks: 8
tony is on a distinguished road
Default

I don't know much about it (i should look more into it), but a google search took me to this 2 sources. They seem good for an understanding of the uses.
tony is offline  
Reply With Quote
Old 06-11-2009, 08:56 AM   #3 (permalink)
The Contributor
 
Sakakuchi's Avatar
 
Join Date: Feb 2009
Posts: 65
Thanks: 1
Sakakuchi is on a distinguished road
Default

To make a fully working Page with UTF8 encoding you just need to follow some simple rules:

1. Make sure your Database Fields are throughout UTF8 encoded.

2. Make the Database Connection to UTF8. Just fire right after you opened the DB-Connection the following query:
PHP Code:
mysql_query("SET NAMES utf8"); 
You could also when building a new Database set the encoding of the connection (But I would recomend to keep the mysql-query since you never know, wheter you'll change the Database once etc.).

3. Next set the encoding in your IDE to UTF8. Under Eclipse you'll find it under 'Edit/Set Encoding' = for 1 File or under 'Project/Preferences/Resource' = whole Project. Every proper Editor should be able to Set File encodings

4. Now that we have everything done on our Server Side - we just need to make sure that the Browser knows that some UTF8 encoded Data is comming - start of with the PHP header:
PHP Code:
header("Content-Type: text/html; charset=utf-8"); 
Now we just add a Meta Tag to our HTML where it also says that this Data is UTF8 encoded, to make double sure that the browser interprets our data as UTF8:

HTML Code:
 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

utf8_encode() and -decode() - you would only need when you want to have Plaintext e.g. you comunicate with an external site (e.g. SMS-interface etc.) - and need to pass plain text there. Or need to convert the UTF-8 to some other format (Some pervert Example since I cant think of an better): your Database is not UTF-8 encoded - so you take the data comming from there - decode it to plaintext - and encode it again to utf8 - and now can fire it out to the browser
Sakakuchi is offline  
Reply With Quote
The Following 2 Users Say Thank You to Sakakuchi For This Useful Post:
ChrisR (06-19-2009), Runar (06-12-2009)
Old 06-12-2009, 03:16 AM   #4 (permalink)
The Wanderer
 
Join Date: Dec 2008
Posts: 15
Thanks: 2
ChrisR is on a distinguished road
Default

@Sakakuchi

thanx ill give that ago.
ChrisR is offline  
Reply With Quote
Old 06-12-2009, 09:14 AM   #5 (permalink)
The Wanderer
 
Join Date: Jun 2009
Posts: 7
Thanks: 0
zongliang is on a distinguished road
Default

Sakakuchi is right, i just now developed a project with full utf-8.
zongliang is offline  
Reply With Quote
Old 12-20-2009, 03:02 AM   #6 (permalink)
The Visitor
 
Join Date: Aug 2009
Posts: 4
Thanks: 2
thanhtung90 is on a distinguished road
Default

I did execute commands but every pages still display " ??? ".
thanhtung90 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Replication support in Zend Framework Orc General 2 05-12-2009 07:03 PM
Virtual Directory Support? delayedinsanity General 2 04-29-2008 08:38 PM
Encoding (utf8) problems Devels Advanced PHP Programming 3 02-24-2008 02:19 PM
International Character Support aristoworks MySQL & Databases 4 11-29-2007 08:36 PM
Support TalkPHP & Use The Banners mike.fro News and Announcements 1 03-30-2007 03:22 AM


All times are GMT. The time now is 01:54 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design