Advertisement:

Author Topic: From messed up in utf-8 encoding  (Read 11088 times)

Offline CapriSkye

  • Full Member
  • ***
  • Posts: 574
    • Open
From messed up in utf-8 encoding
« on: January 23, 2005, 12:17:31 PM »
my forum is in utf-8 chinese encoding, and whenever i get notifications for new replys, the From field is messed. it contains the name of the forum, which is in chinese.
one of the users on my forum managed to find a solution for this, and here's what he did.

in Subs-Post.php,
Find:
Code: [Select]
$headers = 'From: "' . addcslashes($from !== null ? $from : $context['forum_name'], '<>[]()\'\\"') . '" <' . $webmaster_email . ">\r\n";

Add Before:
Code: [Select]
// MIME encode the from(forum_name) - this is tricksy.
for ($i = 0; $i < strlen($context['forum_name']); $i++)
if (ord($context['forum_name']{$i}) > 128 || $context['forum_name']{$i} == '=' || $context['forum_name']{$i} == '?' || $context['forum_name']{$i} == '_')
{
// Add on to the string whenever we find a special character.
$context['forum_name']= substr($context['forum_name'], 0, $i) . '=' . strtoupper(dechex(ord($context['forum_name']{$i}))) . substr($context['forum_name'], $i + 1);
$i18n_char = true;
}

if (!empty($i18n_char))
$context['forum_name'] = '=?' . $txt['lang_character_set'] . '?Q?' . $context['forum_name'] . '?=';

basically just use the MIME encode code for subject and replace it with forum_name. not sure why the code above isn't used for from field, maybe the developers have their own reasoning? if not can this be included in next version? thanks

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: From messed up in utf-8 encoding
« Reply #1 on: January 23, 2005, 12:56:35 PM »
 ! MIME encode the sender's name when sending emails. (Subs-Post.php)

1.1.

-[Unknown]

Offline CapriSkye

  • Full Member
  • ***
  • Posts: 574
    • Open
Re: From messed up in utf-8 encoding
« Reply #2 on: January 23, 2005, 11:48:46 PM »
thank you :)