• Welcome to Simple Machines Community Forum. Please login or sign up.
September 23, 2021, 07:08:42 PM

News:

SMF 2.1 RC4 has been released! Try it out and help us test! :) Read more.


From messed up in utf-8 encoding

Started by CapriSkye, January 23, 2005, 12:17:31 PM

Previous topic - Next topic

CapriSkye

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:

$headers = 'From: "' . addcslashes($from !== null ? $from : $context['forum_name'], '<>[]()\'\\"') . '" <' . $webmaster_email . ">\r\n";


Add Before:

// 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

[Unknown]

 ! MIME encode the sender's name when sending emails. (Subs-Post.php)

1.1.

-[Unknown]


Advertisement: