Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rossy
Created November 19, 2017 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossy/1866e4f8fdd5a9a675cdc5f5cbd5d5d0 to your computer and use it in GitHub Desktop.
Save rossy/1866e4f8fdd5a9a675cdc5f5cbd5d5d0 to your computer and use it in GitHub Desktop.
#define __USE_MINGW_ANSI_STDIO 1
#include <stdint.h>
#include <stdio.h>
#include <locale.h>
int main()
{
_locale_t c = _create_locale(LC_ALL, "C");
_locale_t fr = _create_locale(LC_ALL, "french");
printf("The decimal point separator is '%s'\n", localeconv()->decimal_point);
printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5);
__mingw_printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5);
_printf_l("%lld %jd %zd %.1f\n", c, 1ll, (intmax_t)1, (size_t)1, 1.5);
_printf_l("%lld %jd %zd %.1f\n", fr, 1ll, (intmax_t)1, (size_t)1, 1.5);
if (!setlocale(LC_ALL, "french")) {
printf("Can't change locale\n");
return 1;
}
printf("The decimal point separator is '%s'\n", localeconv()->decimal_point);
printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5);
__mingw_printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5);
_printf_l("%lld %jd %zd %.1f\n", c, 1ll, (intmax_t)1, (size_t)1, 1.5);
_printf_l("%lld %jd %zd %.1f\n", fr, 1ll, (intmax_t)1, (size_t)1, 1.5);
}
// Output:
// The decimal point separator is '.'
// 1 1 1 1.5
// 1 1 1 1.5
// 1 jd zd 0.0
// 1 jd zd 0,0
// The decimal point separator is ','
// 1 1 1 1,5
// 1 1 1 1,5
// 1 jd zd 0.0
// 1 jd zd 0,0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment