C locale.h Functions

Beginner
6 min read
Updated: Nov 2026
2 tutorials
<locale.h>

Definition and Usage

<locale.h> is the C header for simple localization. Its two functions are setlocale(), which changes or queries cultural rules, and localeconv(), which reads numeric and monetary formatting fields for the active locale.

This page is the catalog for both tutorials. Start from the beginner overview if categories and the C locale are new, then open each function guide for syntax, return values, and three examples.

Need the model first?

Read C Locales for LC_ALL, the C locale, environment locales, and struct lconv.

Choose a Function by Job

I want to...Start with
Change or query the localesetlocale()
Use the portable C localesetlocale(LC_ALL, "C")
Use the environment localesetlocale(LC_ALL, "")
Read decimal_point or currency fieldslocaleconv()

C locale.h Functions Index

FunctionDescriptionTutorial
localeconv()Read numeric and monetary formatting fields.Open
setlocale()Change or query the program locale.Open

Key Takeaways

  • Programs start in C. Use setlocale(LC_ALL, "C") to stay portable, or "" for the environment.
  • Check for NULL. A failed setlocale() leaves the previous locale unchanged.
  • localeconv is a snapshot. Copy strings you need if you change the locale again later.

Frequently Asked Questions

It declares setlocale() and localeconv(), plus category macros such as LC_ALL and LC_NUMERIC.
Start with setlocale() to change or query the locale, then localeconv() to read decimal_point and related fields.
The portable default. Select it with setlocale(LC_ALL, "C"). Programs start there unless you change it.
It sets all categories from the environment. On success it returns a locale name; on failure it returns NULL.
setlocale() changes or queries the locale. localeconv() reads formatting details for the locale that is already active.

Start with setlocale()

Learn how to change or query the program locale first.

setlocale() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful