<commit_before><?php
/*=========================================================================
 MIDAS Server
 Copyright (c) Kitware SAS. 26 <NAME>. 69100 Villeurbanne, FRANCE
 All rights reserved.
 More information http://www.kitware.com

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0.txt

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
=========================================================================*/

/** tools for detecting non utf8 files and tranforming non utf8 files to utf8. */
class Utf8tools
  {
  protected $excludedDirs = array('data', 'library', 'tmp', '.git', 'log', 'bin');
  protected $excludedExts = array('ini', 'jpg', 'png', 'gif', 'swf', 'jar', 'ico', 'psd', 'swc', 'keystore');
  protected $excludedFiles = array('.htaccess');

  /**
   * return true if the string is UTF8 encoded.
   */
  protected function isUtf8($str)
    { 
    $len = strlen($str); 
    for($i = 0; $i < $len; $i++)
      { 
      $c = ord($str[$i]); 
      if($c > 128)
        { 
        if(($c > 247))
          {
          return false;
          }
        else if($c > 239)
          {
          $bytes = 4;
          }
        else if($c > 223)
          {<commit_msg>Ignore .DS_Store files in UTF-8 test<commit_after><?php
/*=========================================================================
 MIDAS Server
 Copyright (c) Kitware SAS. 2<NAME>. 69100 Villeurbanne, FRANCE
 All rights reserved.
 More information http://www.kitware.com

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0.txt

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
=========================================================================*/

/** tools for detecting non utf8 files and tranforming non utf8 files to utf8. */
class Utf8tools
  {
  protected $excludedDirs = array('data', 'library', 'tmp', '.git', 'log', 'bin');
  protected $excludedExts = array('ini', 'jpg', 'png', 'gif', 'swf', 'jar', 'ico', 'psd', 'swc', 'keystore');
  protected $excludedFiles = array('.DS_Store', '.htaccess');

  /**
   * return true if the string is UTF8 encoded.
   */
  protected function isUtf8($str)
    { 
    $len = strlen($str); 
    for($i = 0; $i < $len; $i++)
      { 
      $c = ord($str[$i]); 
      if($c > 128)
        { 
        if(($c > 247))
          {
          return false;
          }
        else if($c > 239)
          {
          $bytes = 4;
          }
        else if($c > 223)
          {
{'fraction_non_alphanumeric': 0.20439292251372787, 'fraction_numerical': 0.018913971934106162, 'mean_word_length': 2.9939098660170522, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7419488', 'n_tokens_mistral': 968, 'n_tokens_neox': 879, 'n_words': 341}