RE: [PHP] Japanese entry into MySQL and into emails
The issue of entering Japanese into email from a PHP script has been resolved. A key point was that when creating a header for an email, not only should \r\n be used to separate lines, but immediately preceding \r\n should be a space. The end result was to create a variable that goes into the final space in the mail() command where one puts additional headers which looks like this: $headers = $fromaddress . " \r\nContent-Type: text/plain; charset=iso-2022-jp"; Thanks Marek, Eugene, and Edwin for their advice on this matter, and of storing kanji in a MySQL database. -- Cheers! Dave G [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
I have only one advise for you: send yourself an email with the kanji encoding and check the email headers with the headers you set. Dave G wrote: Thank you Edwin, Marek, and Eugene for your responses and advice. For storing the Japanese names in kanji in the database, I've changed the column to "blob". Storing and retrieving the fields seems to work okay in all my tests, and this solution seemed to be the easiest and without any potential impact on the rest of the database. Thank you for this solution. For sending the email in Japanese, I am still not quite getting it. At first I attempted to attach character set information within the mail() command like so: $addheaders = 'From: ' .$email .'\r\nContent-Type: text/html; charset=iso-2022-jp'; mail ($toaddress, $subject, $mailcontent, $addheaders); This sends the mail correctly, but the content is still coming out as ASCII gibberish. I then attempted to use the mb_send_mail() command, like so (this time a "From: " address being the only additional header: mb_language(Japanese); mb_send_mail($toaddress, $subject, $mailcontent, $fromaddress); But this had exactly the same result. I see on the http://jp2.php.net/manual/en/function.mb-send-mail.php web page there is lots of additional comments on the use of mb-send-mail(), but the technical vocabulary is beyond me. Can someone help me tweak this code to successfully send a kanji email? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Japanese entry into MySQL and into emails
Thank you Edwin, Marek, and Eugene for your responses and advice. For storing the Japanese names in kanji in the database, I've changed the column to "blob". Storing and retrieving the fields seems to work okay in all my tests, and this solution seemed to be the easiest and without any potential impact on the rest of the database. Thank you for this solution. For sending the email in Japanese, I am still not quite getting it. At first I attempted to attach character set information within the mail() command like so: $addheaders = 'From: ' .$email .'\r\nContent-Type: text/html; charset=iso-2022-jp'; mail ($toaddress, $subject, $mailcontent, $addheaders); This sends the mail correctly, but the content is still coming out as ASCII gibberish. I then attempted to use the mb_send_mail() command, like so (this time a "From: " address being the only additional header: mb_language(Japanese); mb_send_mail($toaddress, $subject, $mailcontent, $fromaddress); But this had exactly the same result. I see on the http://jp2.php.net/manual/en/function.mb-send-mail.php web page there is lots of additional comments on the use of mb-send-mail(), but the technical vocabulary is beyond me. Can someone help me tweak this code to successfully send a kanji email? -- Cheers! Dave G [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
Hi, On 2003.10.30, at 18:11 Asia/Tokyo, Dave G wrote: PHP Gurus, Hello, I'm new to this list. I'm very much new to PHP, so my questions will be very basic. I have two things I need to do in Japanese: 1. Store people's names in kanji in my MySQL database. To this end, I've set up an INSERT command without doing anything different than usual, and then at the HTML interface, just typed in some Japanese text (on an English Windows XP machine, Opera 7.2, using Microsoft's global IME text entry). When I looked in my database via phpMyAdmin, the field looked like it was filled with ASCII gibberish. Most probably, you're using phpMyAdmin in English. Choose "EUC-JP" when entering or viewing data. 2. Send kanji text via PHPs mail() command. I've set up a form on a web page, that posts to a PHP script that will send me feedback from the users. Again, I didn't set up anything different than I would for English usage. When I received the mail, it came out as ASCII gibberish again. Have you tried the examples here? http://jp2.php.net/manual/en/function.mb-send-mail.php I've searched some on the web, and in this lists archives, and I understand that I can possibly use mbstring functions in order to resolve this. However, the manual for this function on php.net is a little beyond my ability to understand it. I'm confused by the need to set "internal encoding", and/or also setting the "character set". My web site is on a virtual host, and I don't know if I have access to make such adjustments. Can someone please explain in beginners terms how do I set up my PHP scripts to enter Japanese kanji safely into a database and into an email? You'll find some info about "internal encoding" here: And, you'll be able to set the values by using this: http://jp2.php.net/manual/en/function.ini-set.php Make sure to read this as well: http://jp2.php.net/manual/en/configuration.changes.php - E - __ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
On 2003.10.30, at 18:46 Asia/Tokyo, Eugene Lee wrote: On Thu, Oct 30, 2003 at 10:36:37AM +0100, Marek Kilimajer wrote: : : Unless you want to do string manipulation you don't need mbstring. You : only need to pay atention to these details: : 1. Set charset to kanji for your html pages using : header('Content-type: text/html; charset=kangi'); a. it's spelled "kanji" and not "kangi". b. "charset=ISO-2022-JP". Although that would work, I wonder if it'd be easy to find an editor for that... It's usually used for e-mails though. It's always a good idea to use "EUC-JP" (or, if possible, UTF-8). For "shift_jis", here's a note from the manual: http://jp2.php.net/manual/en/ref.mbstring.php Note: SJIS should not be used for internal encoding unless the reader is familiar with parser/compiler, character encoding and character encoding issues. - E - __ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
Please, include the list's address in cc. You will have much higher chance to get an answer. Dave G wrote: With regards to the kanji field in the MySQL database: Only one field in one table uses kanji. There are seven other tables. Will setting the character set to charset=ISO-2022-JP have any impact on all the straight English input in the database? As I suppose kanji contains also the latin alphabet with the same character codes as ascii, it will not. But you might have trouble searching on the column (case folding according to latin1). Mysql can be configured to use other encodings but the change is server wide and you are on a shared host. I think you should set the column type to BLOB, no text transformation takes place in this case. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
I'm sorry, I have never worked with Japanese. ;) Eugene Lee wrote: On Thu, Oct 30, 2003 at 10:36:37AM +0100, Marek Kilimajer wrote: : : Unless you want to do string manipulation you don't need mbstring. You : only need to pay atention to these details: : 1. Set charset to kanji for your html pages using : header('Content-type: text/html; charset=kangi'); a. it's spelled "kanji" and not "kangi". b. "charset=ISO-2022-JP". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
On Thu, Oct 30, 2003 at 10:36:37AM +0100, Marek Kilimajer wrote: : : Unless you want to do string manipulation you don't need mbstring. You : only need to pay atention to these details: : 1. Set charset to kanji for your html pages using : header('Content-type: text/html; charset=kangi'); a. it's spelled "kanji" and not "kangi". b. "charset=ISO-2022-JP". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
Unless you want to do string manipulation you don't need mbstring. You only need to pay atention to these details: 1. Set charset to kanji for your html pages using header('Content-type: text/html; charset=kangi'); 2. In phpMyAdmin choose Japanese with kangi encoding for the interface language. 3. Set kangi encoding for your emails, preferably use a class that allows you to specify encoding easily. Dave G wrote: PHP Gurus, Hello, I'm new to this list. I'm very much new to PHP, so my questions will be very basic. I have two things I need to do in Japanese: 1. Store people's names in kanji in my MySQL database. To this end, I've set up an INSERT command without doing anything different than usual, and then at the HTML interface, just typed in some Japanese text (on an English Windows XP machine, Opera 7.2, using Microsoft's global IME text entry). When I looked in my database via phpMyAdmin, the field looked like it was filled with ASCII gibberish. 2. Send kanji text via PHPs mail() command. I've set up a form on a web page, that posts to a PHP script that will send me feedback from the users. Again, I didn't set up anything different than I would for English usage. When I received the mail, it came out as ASCII gibberish again. I've searched some on the web, and in this lists archives, and I understand that I can possibly use mbstring functions in order to resolve this. However, the manual for this function on php.net is a little beyond my ability to understand it. I'm confused by the need to set "internal encoding", and/or also setting the "character set". My web site is on a virtual host, and I don't know if I have access to make such adjustments. Can someone please explain in beginners terms how do I set up my PHP scripts to enter Japanese kanji safely into a database and into an email? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php