By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

mbstring settings for English/Japanese Environment

P: 41
(A)

I am making a web application that needs to work in both an English/Japanese environment. This web application is intended to manage a company website (news releases, add new companies), and also contains an admin section available to administrators only. During my coding process I did not realize the existence of the mbstring functions since I am still fairly new to PHP. I am attempting to change the mbstring settings in the php.ini file however, I am not sure if it will give me the desired results.

I prefer to work with UTF-8 as I want to leave some room for development in the future.

THINGS I HAVE DONE SO FAR

1. I have made sure that my php, html charsets are utf-8 by setting the character sets in both the php header() and html meta tags.

2. I have attempted to use the following php.ini settings

Expand|Select|Wrap|Line Numbers
  1. [mbstring]
  2. ; language for internal character representation.
  3. mbstring.language = Neutral
  4.  
  5. ; internal/script encoding.
  6. ; Some encoding cannot work as internal encoding.
  7. ; (e.g. SJIS, BIG5, ISO-2022-*)
  8. mbstring.internal_encoding = UTF-8
  9.  
  10. ; http input encoding.
  11. mbstring.http_input = "auto"
  12.  
  13. ; http output encoding. mb_output_handler must be
  14. ; registered as output buffer to function
  15. mbstring.http_output = UTF-8
  16.  
  17. ; enable automatic encoding translation according to
  18. ; mbstring.internal_encoding setting. Input chars are
  19. ; converted to internal encoding by setting this to On.
  20. ; Note: Do _not_ use automatic encoding translation for
  21. ;       portable libs/applications.
  22. mbstring.encoding_translation = On
  23.  
  24. ; automatic encoding detection order.
  25. ; auto means
  26. ;mbstring.detect_order = auto
  27.  
  28. ; substitute_character used when character cannot be converted
  29. ; one from another
  30. ;mbstring.substitute_character = none;
  31.  
  32. ; overload(replace) single byte functions by mbstring functions.
  33. ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
  34. ; etc. Possible values are 0,1,2,4 or combination of them.
  35. ; For example, 7 for overload everything.
  36. ; 0: No overload
  37. ; 1: Overload mail() function
  38. ; 2: Overload str*() functions
  39. ; 4: Overload ereg*() functions
  40. ;mbstring.func_overload = 0
  41.  
  42. ; enable strict encoding detection.
  43. ;mbstring.strict_encoding = Off
  44.  

3. Replaced str functions with mbstr functions where necessary.

Is there anything else I MUST do or SHOULD do in order to make this application work the way I want it to?

(B)
Questions

I am an absolute newb in encodings, so I have a very newbish question. When I set the mbstring.internal_encoding to UTF-8, does that mean the encoding of the actual script is UTF-8?

I am also using mysql (planning to use mysqli later on). Are these functions safe to use with UTF-8?

I know this may be a big topic, and I am not expecting a complete answer, but any help at all would be greatly appreciated.

ENVIRONMENT:

OS: Windows XP MEDIA CENTRE (ENGLISH with IME)
PHP EDITOR: DREAMWEAVER CS3, ZEND STUDIO 5.5, and sometimes plan old NOTEPAD when I am not on my own computer.
SERVER: WAMP SERVER 2.0
HOST: Probably will use a shared hosting company
Dec 13 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Heya, Clai.

You should be good to go from there. PHP 6 will have greatly-enhanced Unicode support, but for now, you're doing all you can.

I am an absolute newb in encodings, so I have a very newbish question. When I set the mbstring.internal_encoding to UTF-8, does that mean the encoding of the actual script is UTF-8?
Nope. That one is set by your text editor.

I am also using mysql (planning to use mysqli later on). Are these functions safe to use with UTF-8?
Yup.

Be sure to set your connection encoding when you connect to MySQL:
Expand|Select|Wrap|Line Numbers
  1. mysql_query("SET NAMES 'utf-8'", $conn);
  2. mysql_query("SET CHARACTER SET 'utf-8'", $conn);
  3.  
Dec 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.