Exemplo n.º 1
0
charset_converter_cptr
charset_converter_c::init(const std::string &charset) {
  std::string actual_charset = charset.empty() ? get_local_charset() : charset;

  std::map<std::string, charset_converter_cptr>::iterator converter = s_converters.find(actual_charset);
  if (converter != s_converters.end())
    return (*converter).second;

#if defined(HAVE_ICONV_H) && defined(SYS_WINDOWS)
  if (iconv_charset_converter_c::is_available(actual_charset) || !windows_charset_converter_c::is_available(actual_charset))
    return charset_converter_cptr(new iconv_charset_converter_c(actual_charset));

  return charset_converter_cptr(new windows_charset_converter_c(actual_charset));

#elif defined(HAVE_ICONV_H)
  return charset_converter_cptr(new iconv_charset_converter_c(actual_charset));

#else
  return charset_converter_cptr(new windows_charset_converter_c(actual_charset));
#endif
}
Exemplo n.º 2
0
#include "common/command_line.h"
#include "common/ebml.h"
#include "common/endian.h"
#include "common/locale.h"
#include "common/logger.h"
#include "common/mm_io.h"
#include "common/strings/utf8.h"

bool g_suppress_info              = false;
bool g_suppress_warnings          = false;
bool g_warning_issued             = false;
std::string g_stdio_charset;
static bool s_mm_stdio_redirected = false;

charset_converter_cptr g_cc_stdio = charset_converter_cptr(new charset_converter_c);
std::shared_ptr<mm_io_c> g_mm_stdio   = std::shared_ptr<mm_io_c>(new mm_stdio_c);

static mxmsg_handler_t s_mxmsg_info_handler, s_mxmsg_warning_handler, s_mxmsg_error_handler;

void
redirect_stdio(const mm_io_cptr &stdio) {
  g_mm_stdio            = stdio;
  s_mm_stdio_redirected = true;
  g_mm_stdio->set_string_output_converter(g_cc_stdio);
}

bool
stdio_redirected() {
  return s_mm_stdio_redirected;
}