cancel
Showing results for 
Search instead for 
Did you mean: 

May be more a problem with newlib or armgcc, but.. How to change the decimal separator from dot to coma in printf (and sprintf) ?

Xynium
Associate III

May be more a problem with newlib or armgcc, but..

How to change the decimal separator from dot to coma in printf (and sprintf) ?

3 REPLIES 3

setlocale() LC_NUMERIC ??​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Xynium
Associate III

Hi,

I have tried 3 ways but still got a point

 //A struct lconv *ptrLocale = localeconv(); //***

 // ptrLocale->decimal_point[0] = ',';

   //B setlocale(LC_NUMERIC, "fr_FR");

   locale_t loc = newlocale(LC_NUMERIC_MASK, "fr_FR", (locale_t) 0);

   uint8_t str[100];

   sprintf((char*) str, "%.2f ",12.36);

I use a stm32F746 disco with freertos and stm32ide 1.4

Regards,

JP

Alnef
Associate

Hi,

A bit late but for me it worked with:

struct lconv *p_locale = localeconv();
p_locale->decimal_point = ",";

Regards,

AL