How to configure phpList with non-UTF-8 charsets

General talk about translations & I18n (Internationalization)

How to configure phpList with non-UTF-8 charsets

Postby H2B2 » 12:25am, Tue 23 Nov, 2010

Configuring phpList for use with special characters (non-ascii characters) is fairly complex. Currently you will need to make sure all charset settings of your system are correctly configured in four different places:
1. Charset for messages, found on the 'configuration page'
2. Charset of public pages, as defined in your frontend language file (e.g. in lists/texts/french.inc)
3. Charset of admin interface pages, as defined in the language_info file (e.g. in lists/admin/lan/fr/ )
4. Database encoding

Since phpList developers decided to hardcode UTF-8, you may run into trouble if you want to use another charset than UTF-8, or if your system is not fully configured for UTF-8. For more info on how to configure your system for UTF-8, see viewtopic.php?p=81753#p81753

If you want to use a charset encoding different from UTF-8, you will need to make a number of changes in the phpList code. Basically, you will need to change all instances of UTF-8 to strCharSet in the following 6 files:
    admin/class.phplistmailer.php around lines 90, 99
    admin/processbounces.php around line 65
    admin/processqueue.php around line 251
    admin/sendemaillib.php around line 903
    admin/send_core.php around lines 1034, 1035, 1036, 1042, 1048, 1059
    admin/commonlib/lib/maillib.php around line 101

Removing UTF-8 hardcoding - detailed instructions

For those that need detailed instructions on the changes that need to be made:

1. In admin/ send_core.php, you will need to make the following changes:
1.1) At line 1042, change this:
Code: Select all
    value="'.htmlentities($subject,ENT_QUOTES,'UTF-8').'" size=40></td></tr>
to this:
Code: Select all
    value="'.htmlentities($subject,ENT_QUOTES,'strCharSet').'" size=40></td></tr>


1.2) At line 1048, change this:
Code: Select all
   value="'.htmlentities($from,ENT_QUOTES,'UTF-8').'" size=40></td></tr>
to this:
Code: Select all
   value="'.htmlentities($from,ENT_QUOTES,'strCharSet').'" size=40></td></tr>


1.3) At line 1059, change this:
Code: Select all
    value="'.htmlentities($forwardsubject,ENT_QUOTES,'UTF-8').'" size=40></td></tr>
to this:
Code: Select all
    value="'.htmlentities($forwardsubject,ENT_QUOTES,'strCharSet').'" size=40></td></tr>


2. In admin/commonlib/lib/maillib.php, line 99, change this:
Code: Select all
  # eze
  # $text = html_entity_decode ( $text , ENT_QUOTES , $GLOBALS['strCharSet'] );
  $text = html_entity_decode ( $text , ENT_QUOTES , 'UTF-8' );

to this:
Code: Select all
  # eze
  $text = html_entity_decode ( $text , ENT_QUOTES , $GLOBALS['strCharSet'] );
  # $text = html_entity_decode ( $text , ENT_QUOTES , 'UTF-8' );


3. In admin/sendemaillib.php, line 901, change this:
Code: Select all
  # eze
  # $text = html_entity_decode ( $text , ENT_QUOTES , $GLOBALS['strCharSet'] );
  $text = html_entity_decode ( $text , ENT_QUOTES , 'UTF-8' );

to this:
Code: Select all
 
 # eze
  $text = html_entity_decode ( $text , ENT_QUOTES , $GLOBALS['strCharSet'] );
  # $text = html_entity_decode ( $text , ENT_QUOTES , 'UTF-8' );


4. In admin/class.phplistmailer.php,
4.1) at line 90, change this:
Code: Select all
        $this->Body = html_entity_decode($text ,ENT_QUOTES, 'UTF-8' ); #$text;
#        $this->Body = $text;
       } else {
        $this->AltBody = html_entity_decode($text ,ENT_QUOTES, 'UTF-8' );#$text;

to this:
Code: Select all
        $this->Body = html_entity_decode($text ,ENT_QUOTES, 'strCharSet' ); #$text;
#        $this->Body = $text;
       } else {
        $this->AltBody = html_entity_decode($text ,ENT_QUOTES, 'strCharSet' );#$text;


4.2) and at line 99, change this:
Code: Select all
        $this->AltBody .= html_entity_decode($text ,ENT_QUOTES, 'UTF-8' );#$text;
      } else {
        $this->Body .= html_entity_decode($text."\n" ,ENT_QUOTES, 'UTF-8' );#$text;

to this:
Code: Select all
        $this->AltBody .= html_entity_decode($text ,ENT_QUOTES, 'strCharSet' );#$text;
      } else {
        $this->Body .= html_entity_decode($text."\n" ,ENT_QUOTES, 'strCharSet' );#$text;


5. In admin/processbounces.php, at line 65, change this:
Code: Select all
  $message = html_entity_decode($message,ENT_QUOTES,'UTF-8');

tot this:
Code: Select all
  $message = html_entity_decode($message,ENT_QUOTES,'strCharSet');


6. In admin/processqueue.php, at line 251, change this:
Code: Select all
      $line = html_entity_decode($line,ENT_QUOTES,'UTF-8');

to this:
Code: Select all
      $line = html_entity_decode($line,ENT_QUOTES,'strCharSet');


Note:
- The value of the strCharSet variable is taken from the strCharSet setting in your frontend language file, e.g. french.inc
- Make sure that the charset setting of your admin interface is correctly configured (language_info )
- Make sure that the charset of your messages is correctly set. On the configuration page (lists/admin/?page=configure), check:
    Charset for HTML messages:
    Charset of Text messages:

Important: logout/flush browser cache/login, and run your tests with newly created messages only.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

How to configure phpList with ISO-8859-1

Postby H2B2 » 8:34pm, Tue 23 Nov, 2010

The following example illustrates how to configure your system for use with ISO-8859-1 encoding, after having made the above code changes.

In order to work correctly, all relevant charset settings must point in the same direction:

    1. Charset for messages
    On the 'configuration page', check these settings:
    - Charset for HTML messages: ISO-8859-1
    - Charset for Text messages: ISO-8859-1

    2. Charset of public pages
    The charset of public pages can be set in the language file you configured in in config.php (e.g. $language_module = "your_language.inc"; )
    Check this in your_language.inc: $strCharSet = 'ISO-8859-1';
    Note: make sure that lists/texts/your_language.inc is actually encoded in ISO-8859-1.

    3. Charset of admin interface pages
    Since v2.10.11, the charset of admin interface pages should be set to ISO-8859-1 in the language_info file that corresponds to the admin language you selected. In the case of English, you will need to add a language_info file to lists/admin/lan/en/ with the following contents:
    Code: Select all
    name=English
    charset=ISO-8859-1
    Note: If you are using another admin language than English, the corresponding language_info file probably already exists. Just check its contents to make sure it is set to ISO-8859-1. For instance, if you select Spanish as the language to use in the administrator interface, check lists/admin/lan/es/language_info

    4. Database encoding (in phpMyAdmin: SHOW VARIABLES LIKE 'character_set_%' )
    character_set_client: latin1
    character_set_connection: latin1
    character_set_database: latin1
    character_set_results: latin1
    character_set_server: latin1
    character_set_system: latin1

    Note: Be careful with changing the database encoding of a production install. Make sure you backup your database before attempting to change its encoding and converting the data it contains. I recommend testing the conversion on a sandbox installation, not directly on your production install.
    For in-depth info on MySQL encoding see: http://mysql.rjweb.org/doc.php/charcoll

When testing your modified setup, best create a new message, as the old message will contain characters that have been saved to the database with an incorrect encoding.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: How to configure phpList with non-UTF-8 charsets

Postby franciscohdv » 3:09am, Fri 09 Sep, 2011

Thank you very much. I have searched a lot for finding a solution to the spanish caracters (accents, and the ñ). With this solution is sending very well the messages.
franciscohdv
phpList newbie
 
Posts: 2
Joined: 2:39am, Fri 09 Sep, 2011

Re: How to configure phpList with non-UTF-8 charsets

Postby RAYNAU » 12:11am, Thu 26 Jan, 2012

Well, there is a version (2.10.17) which has been settled and which runs perfectly in ISO (all languages, except cyrillic... well all latin european languages).
You can download it here :
http://www.domfront-deviation-concertee ... plist.html

it is written in French, but you will easily see what are the files which must be downloaded.

Version is prepared for Apache
RAYNAU
PL Master
 
Posts: 261
Joined: 4:32pm, Tue 03 Jan, 2012

Re: How to configure phpList with non-UTF-8 charsets

Postby RAYNAU » 10:57pm, Fri 03 Feb, 2012

In fact with that version, you only have to keep the config directory and to install it.
You choose your language and normally it should fit for all european languages.
If you try it, please, let us know in order to control :
1°) That everything is ok, because we can have done a mistake
2°) Helping other people who also are looking for resolving the same problem.
RAYNAU
PL Master
 
Posts: 261
Joined: 4:32pm, Tue 03 Jan, 2012


Return to Translators & Internationalization

Who is online

Users browsing this forum: No registered users and 2 guests