Skip to main content
Xynium
Associate III
October 23, 2020
Question

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

  • October 23, 2020
  • 3 replies
  • 932 views

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

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

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
October 24, 2020

setlocale() LC_NUMERIC ??​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Xynium
XyniumAuthor
Associate III
October 24, 2020

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
Visitor II
April 15, 2022

Hi,

A bit late but for me it worked with:

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

Regards,

AL