|
|||||||||||
Technical Support Support Resources
Product Information |
ARM: How to customize a locale used by setlocale()Information in this knowledgebase article applies to:
QUESTIONThe language shown in our target product's touchscreen can be changed from English to German. I want to change the format of numeric characters from English to German accordingly as well, such as showing the number 3,14 in the German format, instead of 3.14 in the English format. I have tried using setlocale() as follows to change the LC_NUMERIC category to de_DE. But the numeric result is still 3.14 in the English format. How can I change the locale to German using setlocale()? #include "locale.h" float f = 3.14; char test[20]; if (setlocale(LC_NUMERIC, "de_DE") == NULL){ printf ("setlocale failed!\n"); } sprintf(test, "Number: %.2f\n", f); printf ("%s\n", test); ANSWERAs written in the Arm C and C++ Library Functions Reference manual, as the second argument of setlocale(), the valid locale values depend on which __use_X_ctype symbol is imported (__use_iso8859_ctype, __use_sjis_ctype, or __use_utf8_ctype), and on user-defined locales. Because in the Arm C and C++ Library, there is no such a locale de_DE defined in any of symbol sets listed above, the locale value de_DE cannot be used directly for setlocale(). A user-defined locale called de_DE has to be customized as follows.
MORE INFORMATION
SEE ALSO
Last Reviewed: Friday, October 30, 2020 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.