<commit_before>/**
 * This file is part of the SEEKS project.
 * Copyright (C) 2011 <NAME>, <EMAIL>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"
#include <iconv.h>
#include <errno.h>

#ifdef FEATURE_ICU
#include "unicode/utypes.h"
#include "unicode/localpointer.h"
#include "unicode/uenum.h"
#include "unicode/ucsdet.h"
#include "unicode/ucnv.h"
#endif

#include <iostream>

char* iconv_convert (const char *from_charset, const char *to_charset, const char *input)
{
  size_t inleft, outleft, converted = 0;
  char *output, *outbuf;
  const char *inbuf;
  size_t outlen;
  iconv_t cd;

  if ((cd = iconv_open (to_charset, from_charset)) == (iconv_t) -1)
    return NULL;

  inleft = strlen (input);
  inbuf = input;

  /* we'll start off allocating an output buffer which is the same size
   * as our input buffer. */
  outlen = 2*inleft+1;

  /* we allocate 4 bytes more than what we need for nul-termination... */
  if (!(output = (char*)malloc (outlen + 4))) {<commit_msg>fixed ICU unavailable header on Ubuntu<commit_after>/**
 * This file is part of the SEEKS project.
 * Copyright (C) 2011 <NAME>, <EMAIL>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"
#include <iconv.h>
#include <errno.h>

#ifdef FEATURE_ICU
#include "unicode/utypes.h"
#include "unicode/uenum.h"
#include "unicode/ucsdet.h"
#include "unicode/ucnv.h"
#endif

#include <iostream>

char* iconv_convert (const char *from_charset, const char *to_charset, const char *input)
{
  size_t inleft, outleft, converted = 0;
  char *output, *outbuf;
  const char *inbuf;
  size_t outlen;
  iconv_t cd;

  if ((cd = iconv_open (to_charset, from_charset)) == (iconv_t) -1)
    return NULL;

  inleft = strlen (input);
  inbuf = input;

  /* we'll start off allocating an output buffer which is the same size
   * as our input buffer. */
  outlen = 2*inleft+1;

  /* we allocate 4 bytes more than what we need for nul-termination... */
  if (!(output = (char*)malloc (outlen + 4))) {
{'fraction_non_alphanumeric': 0.1027460660290034, 'fraction_numerical': 0.006788028386300524, 'mean_word_length': 3.8100890207715135, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3592851', 'n_tokens_mistral': 1049, 'n_tokens_neox': 992, 'n_words': 425}