[TYPO3-core] Correction to charset setting in t3lib_htmlmail

Martin Kutschker martin.kutschker-n0spam at no5pam-blackbox.net
Mon May 8 22:01:39 CEST 2006


Stanislas Rolland schrieb:
> Martin Kutschker a écrit :
>>> Then, it makes sense for t3lib_htmlmail to use metaCharset to set the
>>> mail headers, does it not?
>>
>> Yes, but there is one problem: the conversion from renderCharset to metaCharset is done automatically after the page generation. But in the case of mail it is up to the calling code to do that.
>>
>> The thing is if you use TYPO3 API calls (FE) they will assume renderCharset. So any strings or file will be in that charset. Fine so far, but if metaCharset comes into play now the conversion should take place. But I don't think it is a very good idea to do a autoconversion on all or some text parts of the mail. It will lead to confusion.
>>
>> So I think the most reasonable default is renderCharset. If somebody wants anything else he should take care fo that and set htmlmail's charset and do the appropriate conversion.
 >
> Ok, then. Patch request dropped.

Why did you drop the request? The current code has issues.

Looking at the code I found more problems. One of them is that you 
cannot set the charset from outside the class. start() will always set a 
default value. But if you set it after start() you have to call 
useQuotedPrintable() again.

This code block lets you set the charset prior to start() and does the 
proper charset detection for FE and BE:

if (!$this->charset) {
  if (is_object($GLOBALS['TSFE']) && $GLOBALS['TSFE']->renderCharset) {
   $this->charset = $GLOBALS['TSFE']->renderCharset;
  } elseif (is_object($GLOBALS['LANG']) && $GLOBALS['LANG']->charSet) {
   $this->charset = $GLOBALS['LANG']->charSet;
  } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']) {
   $this->charset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']
  } else {
   $this->charset = $this->defaultCharset;
  }
}

Masi



More information about the TYPO3-team-core mailing list