Skip to main content
Inspiring
February 6, 2012
Question

PHP Email Subject - in Japanese?

  • February 6, 2012
  • 1 reply
  • 817 views

Bit of an odd one, I know...

I've done a little site in Japanese, and everything works fine, apart from one thing...

I have a mail script for the contact form, but the Japanese tect I've entered for the email subject is incorrectly displaying as ありがとうございます。.

Its fine in English, just not liking the Japanese.

The code looks like:

//start Trigger_SendEmail1 trigger

//remove this line if you want to edit the code by hand

function Trigger_SendEmail1(&$tNG) {

  $emailObj = new tNG_Email($tNG);

  $emailObj->setFrom("info@mywebsite.jp");

  $emailObj->setTo("{email}");

  $emailObj->setCC("");

  $emailObj->setBCC("");

  $emailObj->setSubject("ありがとうございます。");

  //WriteContent method

  $emailObj->setContent("{firstname} 様<br /><br />この度はヒーリングハウス ハイジへのお問い合わせありがとうございます。<br /><br />スタッフが折り返し連絡しますので、今しばらくお待ち下さい。<br /><br />ヒーリングハウス ハイジ");

  $emailObj->setEncoding("ISO-8859-1");

  $emailObj->setFormat("HTML/Text");

  $emailObj->setImportance("Normal");

  return $emailObj->Execute();

}

//end Trigger_SendEmail1 trigger

If anyone has any suggestions to get the subject to display correctly in the Japanese, that would be much appreciated!

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
February 7, 2012

The problem is that you're using Western European encoding, which supports only a limited range of characters. You should be able to use UTF-8 encoding:

Change this:

$emailObj->setEncoding("ISO-8859-1");

to this:

$emailObj->setEncoding("UTF-8");

If that doesn't work, try this:

$emailObj->setEncoding("Shift-JIS");

Shift-JIS is a Japanese-specific encoding. UTF-8 is Unicode, which supports most writing systems, including Japanese.