Example #1
0
void wxXLocale::Init(const char *loc)
{
    if (!loc || *loc == '\0')
        return;

    m_locale = newlocale(LC_ALL_MASK, loc, NULL);
    if (!m_locale)
    {
        // NOTE: here we do something similar to what wxSetLocaleTryUTF8() does
        //       in wxLocale code (but with newlocale() calls instead of wxSetlocale())
        wxString buf(loc);
        wxString buf2;
        buf2 = buf + wxS(".UTF-8");
        m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL);
        if ( !m_locale )
        {
            buf2 = buf + wxS(".utf-8");
            m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL);
        }
        if ( !m_locale )
        {
            buf2 = buf + wxS(".UTF8");
            m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL);
        }
        if ( !m_locale )
        {
            buf2 = buf + wxS(".utf8");
            m_locale = newlocale(LC_ALL_MASK, buf2.c_str(), NULL);
        }
    }

    // TODO: wxLocale performs many more manipulations of the given locale
    //       string in the attempt to set a valid locale; reusing that code
    //       (changing it to take a generic wxTryLocale callback) would be nice
}
Example #2
0
 void prepare_data()
 {
     if(!invalid_)
         return;
     invalid_ = false;
     lc_.reset();
     real_id_ = locale_id_;
     if(real_id_.empty())
         real_id_ = util::get_system_locale();
     
     locale_t tmp = newlocale(LC_ALL_MASK,real_id_.c_str(),0);
     
     if(!tmp) {
         tmp=newlocale(LC_ALL_MASK,"C",0);
     }
     if(!tmp) {
         throw std::runtime_error("newlocale failed");
     }
     
     locale_t *tmp_p = 0;
     
     try {
         tmp_p = new locale_t();
     }
     catch(...) {
         freelocale(tmp);
         throw;
     }
     
     *tmp_p = tmp;
     lc_ = boost::shared_ptr<locale_t>(tmp_p,free_locale_by_ptr);
 }
Example #3
0
int main(int argc, char ** argv)
{
    const char str1[] = "漢字だす";
    const char str2[] = "漢字だす";
    locale_t mylocale1 = newlocale(LC_ALL_MASK, "ja_JP.utf8", (locale_t)NULL);
    locale_t mylocale2 = newlocale(LC_ALL_MASK, "en_GB.utf8", (locale_t)NULL);
    size_t len1 = strlen(str1);
    size_t len2 = strlen(str2);
    size_t ret1, ret2;
    char *xfrm_str1 = alloca(len1 * 10);
    char *xfrm_str2 = alloca(len2 * 10);

    ret1 = strxfrm_l(xfrm_str1, str1, len1 * 10, mylocale1);
    ret2 = strxfrm_l(xfrm_str2, str2, len2 * 10, mylocale2);

    printf("len1 = %lu ret1 = %lu\n", (unsigned long)len1, (unsigned long)ret1);
    printf("len2 = %lu ret2 = %lu\n", (unsigned long)len2, (unsigned long)ret2);
    
    int i;
    printf("Orig: ");
    for (i=0 ; str1[i] ; i++)
        printf("%02x ", (unsigned char)str1[i]); 
    printf("\n");
    printf("Xfrm1: ");
    for (i=0 ; xfrm_str1[i] ; i++)
        printf("%02x ", (unsigned char)xfrm_str1[i]); 
    printf("\n");
    printf("Xfrm2: ");
    for (i=0 ; xfrm_str2[i] ; i++)
        printf("%02x ", (unsigned char)xfrm_str2[i]); 
    printf("\n");
        
    return 0;
}
Example #4
0
static void __config_locale_override(void)
{
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
  && ! defined(__MINGW32__)

  _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
  setlocale(LC_NUMERIC, "C");

#elif defined(__APPLE__)

  locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL);
  uselocale(loc);

#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE))

  locale_t loc = newlocale(LC_NUMERIC, "C", NULL);
  uselocale(loc);

#else

/* locale overriding is pretty pointless (Hercules doesn't make use of the area that uses locale functionality),
 * but I'm actually removing it because it floods the buildbot with warnings  */
//#warning "No way to modify calling thread's locale!"

#endif
}
Example #5
0
static void __config_locale_override(void)
{
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
  && ! defined(__MINGW32__)

  _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
  setlocale(LC_NUMERIC, "C");

#elif defined(__APPLE__)

  locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL);
  uselocale(loc);

#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE))

  locale_t loc = newlocale(LC_NUMERIC, "C", NULL);
  uselocale(loc);

#elif defined(_EE)
  /* do nothing */
#else

#warning "No way to modify calling thread's locale!"

#endif
}
Example #6
0
TEST(locale, newlocale) {
  errno = 0;
  EXPECT_EQ(0, newlocale(1 << 20, "C", 0));
  EXPECT_EQ(EINVAL, errno);

  locale_t l = newlocale(LC_ALL, "C", 0);
  ASSERT_TRUE(l != NULL);
  freelocale(l);

  errno = 0;
  EXPECT_EQ(0, newlocale(LC_ALL, "this-is-not-a-locale", 0));
  EXPECT_EQ(ENOENT, errno); // POSIX specified, not an implementation detail!
}
void *
thread1_execution (void *arg)
{
  char *s;

  waitfor (1);
  uselocale (newlocale (LC_ALL_MASK, LOCALE_DE_ISO8859, NULL));
  setto (2);

  /* Here we expect output in ISO-8859-1.  */

  waitfor (1);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\344se"))
    {
      fprintf (stderr, "thread 1 call 1 returned: %s\n", s);
      result = 1;
    }
  setto (2);

  waitfor (1);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\344se"))
    {
      fprintf (stderr, "thread 1 call 2 returned: %s\n", s);
      result = 1;
    }
  setto (2);

  return NULL;
}
Example #8
0
static void
language_name_get_codeset_details (const char  *language_name,
                                   char       **pcodeset,
                                   gboolean    *is_utf8)
{
        locale_t locale;
        locale_t old_locale;
        const char *codeset = NULL;

        locale = newlocale (LC_CTYPE_MASK, language_name, (locale_t) 0);
        if (locale == (locale_t) 0)
                return;

        old_locale = uselocale (locale);

        codeset = nl_langinfo (CODESET);

        if (pcodeset != NULL) {
                *pcodeset = g_strdup (codeset);
        }

        if (is_utf8 != NULL) {
                g_autofree char *normalized_codeset = normalize_codeset (codeset);

                *is_utf8 = strcmp (normalized_codeset, "UTF-8") == 0;
        }

        uselocale (old_locale);
        freelocale (locale);
}
Example #9
0
int safe_atod(const char *s, double *ret_d) {
        char *x = NULL;
        double d = 0;
        locale_t loc;

        assert(s);
        assert(ret_d);

        loc = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0);
        if (loc == (locale_t) 0)
                return -errno;

        errno = 0;
        d = strtod_l(s, &x, loc);
        if (errno > 0) {
                freelocale(loc);
                return -errno;
        }
        if (!x || x == s || *x) {
                freelocale(loc);
                return -EINVAL;
        }

        freelocale(loc);
        *ret_d = (double) d;
        return 0;
}
Example #10
0
void utf_init(void)
{
    l = newlocale(LC_ALL_MASK, "C.UTF-8", NULL);
#ifdef linux
    uselocale(l);
#endif
}
Example #11
0
/* Return the C locale object, or (locale_t) 0 with errno set
   if it cannot be created.  */
static inline locale_t
c_locale (void)
{
  if (!c_locale_cache)
    c_locale_cache = newlocale (LC_ALL_MASK, "C", (locale_t) 0);
  return c_locale_cache;
}
Example #12
0
File: Sys.cpp Project: vroad/hxcpp
/**
   set_time_locale : string -> bool
   <doc>Set the locale for LC_TIME, returns true on success</doc>
**/
bool _hx_std_set_time_locale( String l )
{
#if defined(ANDROID) || defined(GCW0)
    return false;
#else

#ifdef NEKO_POSIX
   locale_t lc, old;
   lc = newlocale(LC_TIME_MASK,l.__s,NULL);
   if( !lc )
      return false;
   old = uselocale(lc);
   if( !old )
   {
      freelocale(lc);
      return false;
   }
   if( old != LC_GLOBAL_LOCALE )
      freelocale(old);
   return true;
#else
   return setlocale(LC_TIME,l.__s);
#endif

#endif // !Android
}
void *
thread2_execution (void *arg)
{
  char *s;

  waitfor (2);
  uselocale (newlocale (LC_ALL_MASK, "fr_FR.ISO-8859-1", NULL));
  setto (1);

  waitfor (2);
  s = gettext ("beauty");
  puts (s);
  if (strcmp (s, "beaut\351"))
    {
      fprintf (stderr, "thread 2 call 1 returned: %s\n", s);
      result = 1;
    }
  setto (1);

  waitfor (2);
  s = gettext ("beauty");
  puts (s);
  if (strcmp (s, "beaut\351"))
    {
      fprintf (stderr, "thread 2 call 2 returned: %s\n", s);
      result = 1;
    }
  setto (1);

  return NULL;
}
Example #14
0
int
main (void)
{
  locale_t l;
  locale_t l2;
  int result;

  l = newlocale (1 << LC_ALL, "de_DE.ISO-8859-1", NULL);
  if (l == NULL)
    {
      printf ("newlocale failed: %m\n");
      exit (EXIT_FAILURE);
    }
  puts ("Running tests of created locale");
  result = do_test (l);

  l2 = duplocale (l);
  if (l2 == NULL)
    {
      printf ("duplocale failed: %m\n");
      exit (EXIT_FAILURE);
    }
  freelocale (l);
  puts ("Running tests of duplicated locale");
  result |= do_test (l2);

  return result;
}
Example #15
0
void
test_wcsrtombs_thr_iter(test_t t, const char *locale,
    struct wcsrtombs_test *test)
{
	locale_t loc;
	mbstate_t	ms;

	loc = newlocale(LC_ALL_MASK, locale, NULL);
	if (loc == NULL) {
		test_failed(t, "newlocale failed: %s", strerror(errno));
	}

	for (int i = 0; test[i].mbs[0] != 0; i++) {
		char mbs[32];
		const wchar_t *wcs = test[i].wcs;
		size_t cnt;

		(void) memset(&ms, 0, sizeof (ms));
		(void) memset(mbs, 0, sizeof (mbs));
		cnt = wcsrtombs_l(mbs, &wcs, sizeof (mbs), &ms, loc);
		if (cnt != strlen(test[i].mbs)) {
			test_failed(t, "incorrect return value: %d != %d",
			    cnt, strlen(test[i].mbs));
		}
		if (strcmp(mbs, test[i].mbs) != 0) {
			test_failed(t, "wrong result: %s != %s", mbs,
			    test[i].mbs);
		}
		if (extra_debug) {
			test_debugf(t, "mbs is %s", mbs);
		}
	}

	freelocale(loc);
}
Example #16
0
int
override_current_locale(void *data)
{
    save_t *s = data;
    assert(s != NULL && "Must be a valid pointer to `save_t' type");

    s->status = -1;
    s->data.locale.old_locale = NULL;
    s->data.locale.new_locale = NULL;

    s->data.locale.new_locale = newlocale(LC_ALL_MASK, "C", NULL);
    if (s->data.locale.new_locale == (locale_t)0) {
	goto out;
    }

    assert(s->data.locale.new_locale != NULL && \
	    "Must be a valid pointer to `locale_t' type");

    s->data.locale.old_locale = uselocale(s->data.locale.new_locale);
    if (s->data.locale.old_locale == (locale_t)0) {
	goto out;
    }

    assert(s->data.locale.old_locale != NULL && \
	    "Must be a valid pointer to `locale_t' type");

    s->status = 0;

out:
    return s->status;
}
Example #17
0
static locale_t makeCLocale() {
  locale_t CLocale = newlocale(LC_ALL_MASK, "C", nullptr);
  if (!CLocale) {
    swift::crash("makeCLocale: newlocale() returned a null pointer");
  }
  return CLocale;
}
Example #18
0
/** Write a floating point number to the output. */
static void write_number(FILE *file, double value) {
  char buffer[160];
  locale_t prev_locale, c_locale;

  /* Make sure that we have standard representations for not-a-number and
     infinity. Especially NaN is allowed to have extra characters in the C
     specification.
  */
  if (isnan(value)) {
    fprintf(file, "%sNaN", signbit(value) ? "-" : "");
    return;
  } else if (isinf(value)) {
    fprintf(file, "%sInfinity", signbit(value) ? "-" : "");
    return;
  }

  c_locale = newlocale(LC_ALL, "C", (locale_t)0);
  prev_locale = uselocale(c_locale);

  /* Print to buffer, because we want to add .0 if there is no decimal point. */
  sprintf(buffer, "%.18g", value);

  uselocale(prev_locale);
  freelocale(c_locale);

  /* If there is no decimal point, add .0 */
  if (strchr(buffer, '.') == NULL) strcat(buffer, ".0");
  fputs(buffer, file);
  return;
}
Example #19
0
struct mp_archive *mp_archive_new(struct mp_log *log, struct stream *src,
                                  int flags)
{
    struct mp_archive *mpa = talloc_zero(NULL, struct mp_archive);
    mpa->log = log;
    mpa->locale = newlocale(LC_ALL_MASK, "C.UTF-8", (locale_t)0);
    if (!mpa->locale)
        goto err;
    mpa->arch = archive_read_new();
    mpa->primary_src = src;
    if (!mpa->arch)
        goto err;

    // first volume is the primary streame
    if (!add_volume(log ,mpa, src, src->url))
        goto err;

    // try to open other volumes
    char** volumes = find_volumes(src);
    for (int i = 0; volumes[i]; i++) {
        if (!add_volume(log, mpa, NULL, volumes[i])) {
            talloc_free(volumes);
            goto err;
        }
    }
    talloc_free(volumes);

    locale_t oldlocale = uselocale(mpa->locale);

    archive_read_support_format_7zip(mpa->arch);
    archive_read_support_format_iso9660(mpa->arch);
    archive_read_support_format_rar(mpa->arch);
    archive_read_support_format_zip(mpa->arch);
    archive_read_support_filter_bzip2(mpa->arch);
    archive_read_support_filter_gzip(mpa->arch);
    archive_read_support_filter_xz(mpa->arch);
    if (flags & MP_ARCHIVE_FLAG_UNSAFE) {
        archive_read_support_format_gnutar(mpa->arch);
        archive_read_support_format_tar(mpa->arch);
    }

    archive_read_set_read_callback(mpa->arch, read_cb);
    archive_read_set_skip_callback(mpa->arch, skip_cb);
    archive_read_set_switch_callback(mpa->arch, switch_cb);
    archive_read_set_open_callback(mpa->arch, open_cb);
    archive_read_set_close_callback(mpa->arch, close_cb);
    if (mpa->primary_src->seekable)
        archive_read_set_seek_callback(mpa->arch, seek_cb);
    bool fail = archive_read_open1(mpa->arch) < ARCHIVE_OK;

    uselocale(oldlocale);

    if (fail)
        goto err;
    return mpa;

err:
    mp_archive_free(mpa);
    return NULL;
}
Example #20
0
static char *
get_translated_territory (const char *code,
                          const char *locale)
{
        const char *territory;
        char       *name;

        territory = get_territory (code);

        name = NULL;
        if (territory != NULL) {
                const char *translated_territory;
                locale_t loc;
                locale_t old_locale;
                g_autofree char *tmp = NULL;

                if (locale != NULL) {
                        loc = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0);
                        if (loc == (locale_t) 0)
                                return NULL;
                        old_locale = uselocale (loc);
                }

                translated_territory = dgettext ("iso_3166", territory);
                tmp = get_first_item_in_semicolon_list (translated_territory);
                name = capitalize_utf8_string (tmp);

                if (locale != NULL) {
                        uselocale (old_locale);
                        freelocale (loc);
                }
        }

        return name;
}
Example #21
0
int main(int argc, char *argv[])
{
	//On initialise la locale pour recuperer les erreurs de errno dans la langue adéquate */
	locale = newlocale(LC_CTYPE_MASK|LC_NUMERIC_MASK|LC_TIME_MASK|
			LC_COLLATE_MASK|LC_MONETARY_MASK|LC_MESSAGES_MASK,
			"",(locale_t)0);
        if (locale == (locale_t)0) {	    
		return EXIT_FAILURE;
        }
	
	program_name = argv[0];
	current_level = 0;
	stop_at_current_level = false;
	mindepth = -1;
	maxdepth = -1;
	sort = false;
	
	//On parse tous les arguments
	bool path = parse(argv, argc);

	//Si le chemin n'est pas donné on execute le programme sur le repertoire courant
	if(!path) 
		process_top_path(".");
	else
		process_top_path(argv[1]);

	//On libere la memoire
	free_predicates();
	freelocale(locale);
	
	return EXIT_SUCCESS;
}
Example #22
0
void *
thread2_execution (void *arg)
{
  char *s;

  waitfor (2);
  uselocale (newlocale (LC_ALL_MASK, "de_DE.UTF-8", NULL));
  setto (1);

  /* Here we expect output in UTF-8.  */

  waitfor (2);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\303\244se"))
    {
      fprintf (stderr, "thread 2 call 1 returned: %s\n", s);
      result = 1;
    }
  setto (1);

  waitfor (2);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\303\244se"))
    {
      fprintf (stderr, "thread 2 call 2 returned: %s\n", s);
      result = 1;
    }
  setto (1);

  return NULL;
}
Example #23
0
static int do_strtod (char *buf, int sign, double *xp)
{
# if USE_STRTOD_L
   if (C_Locale != (locale_t) 0)
     {
	*xp = sign * strtod_l (buf, NULL, C_Locale);
	return 1;
     }

   C_Locale = newlocale (LC_ALL_MASK, "C", (locale_t) 0);
   if (C_Locale != (locale_t) 0)
     {
	*xp = sign * strtod_l (buf, NULL, C_Locale);
	return 1;
     }
   /* drop */
# endif

# ifdef HAVE_STRTOD
   *xp = sign * strtod (buf, NULL);
# else
   *xp = sign * atof (buf);
# endif
   return 1;
}
void *
thread1_execution (void *arg)
{
  char *s;

  waitfor (1);
  uselocale (newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL));
  setto (2);

  waitfor (1);
  s = gettext ("beauty");
  puts (s);
  if (strcmp (s, "Sch\366nheit"))
    {
      fprintf (stderr, "thread 1 call 1 returned: %s\n", s);
      result = 1;
    }
  setto (2);

  waitfor (1);
  s = gettext ("beauty");
  puts (s);
  if (strcmp (s, "Sch\366nheit"))
    {
      fprintf (stderr, "thread 1 call 2 returned: %s\n", s);
      result = 1;
    }
  setto (2);

  return NULL;
}
Example #25
0
void
_mesa_locale_init(void)
{
#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
   loc = newlocale(LC_CTYPE_MASK, "C", NULL);
#endif
}
Example #26
0
/* Test the gl_locale_name_default() function.  */
static void
test_locale_name_default (void)
{
  const char *name = gl_locale_name_default ();

  ASSERT (name != NULL);

  /* Only MacOS X and Windows have a facility for the user to set the default
     locale.  */
#if !((defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __WIN32__ || defined __CYGWIN__))
  ASSERT (strcmp (name, "C") == 0);
#endif

#if HAVE_NEWLOCALE
  /* Check that gl_locale_name_default ignores the thread locale.  */
  {
    locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
    if (locale != NULL)
      {
        uselocale (locale);
        ASSERT (strcmp (gl_locale_name_default (), name) == 0);
      }
  }
#endif
}
Example #27
0
int curl_parse_http_time(const char *t, usec_t *ret) {
        const char *e;
        locale_t loc;
        struct tm tm;
        time_t v;

        assert(t);
        assert(ret);

        loc = newlocale(LC_TIME_MASK, "C", (locale_t) 0);
        if (loc == (locale_t) 0)
                return -errno;

        /* RFC822 */
        e = strptime_l(t, "%a, %d %b %Y %H:%M:%S %Z", &tm, loc);
        if (!e || *e != 0)
                /* RFC 850 */
                e = strptime_l(t, "%A, %d-%b-%y %H:%M:%S %Z", &tm, loc);
        if (!e || *e != 0)
                /* ANSI C */
                e = strptime_l(t, "%a %b %d %H:%M:%S %Y", &tm, loc);
        freelocale(loc);
        if (!e || *e != 0)
                return -EINVAL;

        v = timegm(&tm);
        if (v == (time_t) -1)
                return -EINVAL;

        *ret = (usec_t) v * USEC_PER_SEC;
        return 0;
}
Example #28
0
/**
	set_time_locale : string -> bool
	<doc>Set the locale for LC_TIME, returns true on success</doc>
**/
static value set_time_locale( value l ) {
#if defined(ANDROID) || defined(GCW0)
        return alloc_null();
#else

#ifdef NEKO_POSIX
	locale_t lc, old;
	val_check(l,string);
	lc = newlocale(LC_TIME_MASK,val_string(l),NULL);
	if( lc == NULL ) return alloc_bool(false);
	old = uselocale(lc);
	if( old == NULL ) {
		freelocale(lc);
		return alloc_bool(false);
	}
	if( old != LC_GLOBAL_LOCALE )
		freelocale(old);
	return alloc_bool(true);
#else
	val_check(l,string);
	return alloc_bool(setlocale(LC_TIME,val_string(l)) != NULL);
#endif

#endif // !Android
}
Example #29
0
locale_t __darwin_newlocale(int category_mask, const char* locale,
                            locale_t base) {
  LOGF("newlocale: %d %p %p\n", category_mask, locale, base);
  int linux_category_mask = 0;
  if (__DARWIN_LC_COLLATE_MASK & category_mask)
    linux_category_mask |= LC_COLLATE_MASK;
  if (__DARWIN_LC_CTYPE_MASK & category_mask)
    linux_category_mask |= LC_CTYPE_MASK;
  if (__DARWIN_LC_MESSAGES_MASK & category_mask)
    linux_category_mask |= LC_MESSAGES_MASK;
  if (__DARWIN_LC_MONETARY_MASK & category_mask)
    linux_category_mask |= LC_MONETARY_MASK;
  if (__DARWIN_LC_NUMERIC_MASK & category_mask)
    linux_category_mask |= LC_NUMERIC_MASK;
  if (__DARWIN_LC_TIME_MASK & category_mask)
    linux_category_mask |= LC_TIME_MASK;
  // Apple's newlocale allows base=LC_GLOBAL_LOCALE, while glibc crashes.
  // It seems the behavior is unspecified for this case.
  // http://pubs.opengroup.org/onlinepubs/9699919799/functions/newlocale.html
  // We'll use current locale (NULL) instead of the global locale.
  if (base == LC_GLOBAL_LOCALE)
    base = NULL;
  // It seems the following 5 locales are the same as "C" for Mac.
  if (!strcmp(locale, "en_US") ||
      !strcmp(locale, "en_US.ISO8859-1") ||
      !strcmp(locale, "en_US.ISO8859-15") ||
      !strcmp(locale, "en_US.US-ASCII") ||
      !strcmp(locale, "en_US.UTF-8"))
    locale = "C";
  return newlocale(linux_category_mask, locale, base);
}
void test_char()
{
    booster::locale::generator gen;

    std::cout << "- Testing at least C" << std::endl;

    std::locale l = gen("en_US.UTF-8");

    test_one<CharType>(l,"Hello World i","hello world i","HELLO WORLD I");

    std::string name = "en_US.UTF-8";
    if(have_locale(name)) {
        std::cout << "- Testing " << name << std::endl;
        std::locale l=gen(name);
        test_one<CharType>(l,"Façade","façade","FAÇADE");
    }
    else {
        std::cout << "- en_US.UTF-8 is not supported, skipping" << std::endl;
    }

    name = "en_US.ISO8859-1";
    if(have_locale(name)) {
        std::cout << "Testing " << name << std::endl;
        std::locale l=gen(name);
        test_one<CharType>(l,"Hello World","hello world","HELLO WORLD");
        #if defined(__APPLE__) || defined(__FreeBSD__)
        if(sizeof(CharType)!=1)
        #endif
            test_one<CharType>(l,"Façade","façade","FAÇADE");
    }
    else {
        std::cout << "- en_US.ISO8859-1 is not supported, skipping" << std::endl;
    }
    
    name = "tr_TR.UTF-8";
    if(have_locale(name)) {
        std::cout << "Testing " << name << std::endl;
        locale_t cl = newlocale(LC_ALL_MASK,name.c_str(),0);
        try { 
            TEST(cl);
            if(towupper_l(L'i',cl) == 0x130) {
                test_one<CharType>(gen(name),"i","i","İ");
            }
            else {
                std::cout <<"  Turkish locale is not supported well" << std::endl;
            }
        }
        catch(...) {
            if(cl) freelocale(cl);
            throw;
        }
        if(cl) freelocale(cl);
        
    }
    else 
    {
        std::cout << "- tr_TR.UTF-8 is not supported, skipping" << std::endl;
    }
}