<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  /**
   * Encodes/decodes for quoted printable data
   *
   * <code>
   *   $b= QuotedPrintable::encode($str);
   *   $str= QuotedPrintable::decode($b);
   * </code>
   *
   * @model    static
   * @see      rfc://2045#6.7
   * @purpose  Quoted Printable encoder / decoder
   */
  class QuotedPrintable extends Object {
  
    /**
     * Get ASCII values of characters that need to be encoded
     *
     * Note: According to RFC 2045, the "@" need not be escaped
     * Exim has its problems though if an "@" sign appears in an 
     * name (even if it's encoded), such as:
     *
     * <pre>
     *   =?iso-8859-1?Q?Timm@Home?= <<EMAIL>>
     * </pre>
     *
     * This is why "64" is added to the first array in this function.
     *
     * @model   static
     * @access  public
     * @return  int[]
     */
    function getCharsToEncode() {
      return array_merge(array(64, 61, 46), range(0, 31), range(127, 255));
    }
  
    /**
     * Encode string
     *
     * @model   static
     * @access  public
     * @param   string str
     * @param   string charset default 'iso-8859-1'
     * @return  string
     */
    function encode($str, $charset= 'iso-8859-1') { 
      $r= array(' ' => '_');<commit_msg>- Improve getCharsToEncode() performance for multiple lookups   by using a static variable to cache the results from array_merge()<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  /**
   * Encodes/decodes for quoted printable data
   *
   * <code>
   *   $b= QuotedPrintable::encode($str);
   *   $str= QuotedPrintable::decode($b);
   * </code>
   *
   * @model    static
   * @see      rfc://2045#6.7
   * @purpose  Quoted Printable encoder / decoder
   */
  class QuotedPrintable extends Object {
  
    /**
     * Get ASCII values of characters that need to be encoded
     *
     * Note: According to RFC 2045, the "@" need not be escaped
     * Exim has its problems though if an "@" sign appears in an 
     * name (even if it's encoded), such as:
     *
     * <pre>
     *   =?iso-8859-1?Q?Timm@Home?= <<EMAIL>>
     * </pre>
     *
     * This is why "64" is added to the first array in this function.
     *
     * @model   static
     * @access  public
     * @return  int[]
     */
    function getCharsToEncode() {
      static $characters = NULL;
      
      if (!isset($characters)) {
        $characters= array_merge(array(64, 61, 46), range(0, 31), range(127, 255));
      }
      
      return $characters;
    }
  
    /**
     * Encode string
     *
     * @model   static
     * @access  public
     * @param   string str
     * @param   string charset default 'iso-8859-1'
     * @return  string
     */
    function encode($str, $charset= 'iso-8859-1') { 
      $r= array(' ' => '_');
{'fraction_non_alphanumeric': 0.13455442057062345, 'fraction_numerical': 0.029587883057414582, 'mean_word_length': 2.0570505920344457, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5003765', 'n_tokens_mistral': 1011, 'n_tokens_neox': 925, 'n_words': 278}