protected function encode(array $messages)
    {
        if ($this->encode) {
            foreach ($messages as $key => $message) {
                if (($form = mb_detect_encoding($message)) != self::TARGET_ENCODING) {
                    $messages[$key] = mb_convert_encoding($message, self::TARGET_ENCODING, $form);
                }
            }
        }

        return $messages;
    }