Your SlideShare is downloading. ×
Characterset
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Characterset

1,081
views

Published on

Dealing with UTF-8 and character set .

Dealing with UTF-8 and character set .

Published in: Technology

1 Comment
2 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,081
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
1
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Character set
      Hari K T Bridge India http://harikt.com Twitter : @harikt
  • 2. Problem ?
  • 6. UTF-8
    • originally proposed by Dave Prosser
    • 7. subsequently modified by Ken Thompson
    • 8. To be backward-compatible with ASCII
    • 9. To enable encoding of up to at least 231 characters (the theoretical limit of the first draft proposal for the Universal Character Set).
    • 10. http://www.cl.cam.ac.uk/~mgk25/ucs/utf-8-history.txt
  • 11. When and where ?
    • Dealing with i18n and L10n
  • 12. How to do ?
    • <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; />
    • 13. Must be the first thing to be in <head>
    • 14. Remember Google UTF-7 exploit read on http://shiflett.org/archive/178
    • 15. Changing the server encoding
  • 16. Server encoding
    • PHP header function
    • 17. header('Content-Type:text/html; charset=UTF-8');
    • 18. php.ini
    • 19. default_charset = &quot;utf-8&quot;
    • 20. ini_set('default_charset', 'UTF-8');
    • 21. Running php as a module in apache and not fast cgi
    • 22. php_value default_charset &quot;UTF-8&quot;
    • 23. AddDefaultCharset UTF-8 in .htaccess
  • 24. Force the forms
    • Add accept-charset .
    • 25. Eg :
    • 26. <form accept-charset=&quot;utf-8&quot; ...>
  • 27. MySql
    • DB utf8_general_ci
    • 28. mysql_set_charset('utf8');
    • 29. mysqli_set_charset('utf8');
    • 30. Remember we are moving to PDO ;)
    • 31. $handle = new PDO(&quot;mysql:host=localhost;dbname=dbname&quot;,
    • 32. 'username', 'password',
    • 33. array (PDO::MYSQL_ATTR_INIT_COMMAND => &quot;SET NAMES utf8&quot;));
  • 34. Inside Zend Framework
    • $params = array( 'host' => 'localhost',
      • 'username' => 'username',
      • 35. 'password' => 'password',
      • 36. 'dbname' => 'dbname',
      • 37. 'driver_options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8 ;')
      • 38. );
    • $db = Zend_Db::factory(' PDO_MYSQL ', $params);
    • 39. Or in config/application.ini
    • 40. resources.db.params.charset = utf8
  • 41. With Symfony2 ?
    • In app/config/config.yml
    • 42. # Doctrine Configuration
    • 43. doctrine:
    • 44. dbal:
    • 45. driver: %database_driver%
    • 46. host: %database_host%
    • 47. port: %database_port%
    • 48. dbname: %database_name%
    • 49. user: %database_user%
    • 50. password: %database_password%
    • 51. charset: UTF8
  • 52. Samples
    • Sample application ;)
    • 53. Show size of byte with utf-8 and latin charcter-set.
    • 54. EXPLAIN SELECT * FROM tbl WHERE first_name LIKE 'joshua';
  • 55. Questions ?
  • 56. References
    • http://www.joelonsoftware.com/articles/Unicode.html
    • 57. http://htmlpurifier.org/docs/enduser-utf8.html
    • 58. http://en.wikipedia.org/wiki/UTF-8
    • 59. http://webcollab.sourceforge.net/unicode.html
    • 60. http://akrabat.com/php/utf8-php-and-mysql/
    • 61. http://www.adayinthelifeof.nl/2010/12/04/about-using-utf-8-fields-in-mysql