# locale

***

**1. Set the Locale for the Current Thread**

```c
#include <locale.h>
int setlocale(int category, const char *locale);
```

Sets the locale for the specified category for the current thread.

**2. Get the Current Locale**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Returns the current locale for the specified category.

**3. Convert a String to Uppercase**

```c
#include <locale.h>
char *strupr(char *s);
```

Converts the string `s` to uppercase.

**4. Convert a String to Lowercase**

```c
#include <locale.h>
char *strlwr(char *s);
```

Converts the string `s` to lowercase.

**5. Compare Two Strings Case-Insensitively**

```c
#include <locale.h>
int strcasecmp(const char *s1, const char *s2);
```

Compares the two strings `s1` and `s2` case-insensitively.

**6. Copy a String**

```c
#include <locale.h>
char *strcpy(char *dest, const char *src);
```

Copies the string `src` to the string `dest`.

**7. Concatenate Two Strings**

```c
#include <locale.h>
char *strcat(char *dest, const char *src);
```

Concatenates the string `src` to the end of the string `dest`.

**8. Get the Length of a String**

```c
#include <locale.h>
size_t strlen(const char *s);
```

Returns the length of the string `s`.

**9. Find a Character in a String**

```c
#include <locale.h>
char *strchr(const char *s, int c);
```

Returns a pointer to the first occurrence of the character `c` in the string `s`.

**10. Find the Last Occurrence of a Character in a String**

```c
#include <locale.h>
char *strrchr(const char *s, int c);
```

Returns a pointer to the last occurrence of the character `c` in the string `s`.

**11. Split a String into Tokens**

```c
#include <locale.h>
char *strtok(char *str, const char *delim);
```

Splits the string `str` into tokens based on the delimiter `delim`.

**12. Convert a Number to a String**

```c
#include <locale.h>
char *itoa(int num, char *str, int radix);
```

Converts the integer `num` to a string `str` in the specified radix `radix`.

**13. Convert a String to a Number**

```c
#include <locale.h>
long int atol(const char *str);
```

Converts the string `str` to a long integer.

**14. Format a Number**

```c
#include <locale.h>
char *strftime(char *str, size_t maxsize, const char *format,
               const struct tm *tm);
```

Formats the time specified by the `tm` structure according to the format string `format`.

**15. Get the Current Time**

```c
#include <locale.h>
time_t time(time_t *tloc);
```

Returns the current time as a time\_t value.

**16. Convert a Time\_t Value to a String**

```c
#include <locale.h>
char *ctime(const time_t *tloc);
```

Converts the time\_t value `tloc` to a string.

**17. Convert a String to a Time\_t Value**

```c
#include <locale.h>
time_t mktime(struct tm *tm);
```

Converts the `tm` structure to a time\_t value.

**18. Get the Current Date and Time**

```c
#include <locale.h>
struct tm *localtime(const time_t *tloc);
```

Gets the current date and time as a `tm` structure.

**19. Set the Current Date and Time**

```c
#include <locale.h>
struct tm *gmtime(const time_t *tloc);
```

Sets the current date and time from the time\_t value `tloc`.

**20. Get the Julian Day Number**

```c
#include <locale.h>
int julian_day(const struct tm *tloc);
```

Calculates the Julian day number for the given `tm` structure.

**21. Get the Day of the Year**

```c
#include <locale.h>
int day_of_year(const struct tm *tloc);
```

Returns the day of the year for the given `tm` structure.

**22. Get the Day of the Week**

```c
#include <locale.h>
int weekday(const struct tm *tloc);
```

Returns the day of the week for the given `tm` structure.

**23. Get the Week of the Year**

```c
#include <locale.h>
int week_of_year(const struct tm *tloc);
```

Returns the week of the year for the given `tm` structure.

**24. Convert a Time Zone String to a Time Zone Structure**

```c
#include <locale.h>
struct tm *timezone(const char *tloc);
```

Converts the time zone string `tloc` to a `tm` structure.

**25. Convert a Time Zone Structure to a Time Zone String**

```c
#include <locale.h>
char *tzname[2];
```

Converts the `tm` structure to a time zone string.

**26. Get the Time Zone Offset**

```c
#include <locale.h>
int timezone;
```

Returns the time zone offset in seconds from UTC.

**27. Get the Daylight Savings Time Offset**

```c
#include <locale.h>
int daylight;
```

Returns the daylight savings time offset in seconds from UTC.

**28. Get the Current Character Set**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current character set to the locale `locale`.

**29. Get the Current Collation Order**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current collation order to the locale `locale`.

**30. Get the Current Monetary Format**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current monetary format to the locale `locale`.

**31. Get the Current Numeric Format**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current numeric format to the locale `locale`.

**32. Get the Current Time Format**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current time format to the locale `locale`.

**33. Get the Current Date Format**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current date format to the locale `locale`.

**34. Get the Current Measurement System**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current measurement system to the locale `locale`.

**35. Get the Current Paper Size**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current paper size to the locale `locale`.

**36. Get the Current Language**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current language to the locale `locale`.

**37. Get the Current Country**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the current country to the locale `locale`.

**38. Get the Current Locale Name**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Returns the name of the current locale.

**39. Create a New Locale**

```c
#include <locale.h>
locale_t newlocale(int locale_mask, const char *locale, locale_t base);
```

Creates a new locale with the specified locale mask, locale, and base locale.

**40. Destroy a Locale**

```c
#include <locale.h>
int freelocale(locale_t locale);
```

Destroys the specified locale.

**41. Duplicate a Locale**

```c
#include <locale.h>
locale_t duplocale(locale_t locale);
```

Duplicates the specified locale.

**42. Get the Locale Categories**

```c
#include <locale.h>
int locale_catmasks(int locale_mask, locale_t locale);
```

Returns the locale categories that are set in the specified locale mask.

**43. Mask a Locale Category**

```c
#include <locale.h>
int locale_set_categorymask(int locale_mask, int category);
```

Sets the locale category mask to the specified value.

**44. Unmask a Locale Category**

```c
#include <locale.h>
int locale_unset_categorymask(int locale_mask, int category);
```

Unsets the locale category mask for the specified category.

**45. Get the Locale Attributes**

```c
#include <locale.h>
int locale_get_attributes(locale_t locale);
```

Returns the locale attributes for the specified locale.

**46. Set the Locale Attributes**

```c
#include <locale.h>
int locale_set_attributes(locale_t locale, int attributes);
```

Sets the locale attributes for the specified locale.

**47. Compare Two Locales**

```c
#include <locale.h>
int locale_compare(locale_t locale1, locale_t locale2);
```

Compares two locales and returns 0 if they are equal.

**48. Merge Two Locales**

```c
#include <locale.h>
locale_t locale_merge(locale_t locale1, locale_t locale2);
```

Merges two locales into a new locale.

**49. Get the Locale Environment**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Gets the locale environment for the specified category.

**50. Set the Locale Environment**

```c
#include <locale.h>
char *setlocale(int category, const char *locale);
```

Sets the locale environment for the specified category.
