Questions tagged [setlocale]

The setlocale() is a function that is used to configure and specify certain locale information.

The setlocale() is a function that is used to configure and specify certain locale category information. Such locale categories can be:

  • LC_ALL
  • LC_COLLATE
  • LC_CTYPE
  • LC_MONETARY
  • LC_NUMERIC
  • LC_TIME
  • LC_MESSAGES

Additionally, the locale must be specified. The locale is actually the universal locale code of the currently language.

The possible locale and category values are specified in RFC 1766 and ISO 639.

249 questions
3
votes
1 answer

fgets isn't using the set up locale

Considering the following code: #include #include int main() { char test[100]; printf("WITHOUT LOCALE: á, é, í, ó, ú, ü, ñ, ¿, ¡\n"); setlocale(LC_CTYPE, "Spanish"); printf("WITH LOCALE: á, é, í, ó, ú, ü, ñ,…
Kurolox
  • 147
  • 8
3
votes
3 answers

Sorting PHP array with locale setting?

Is it possible to sort a PHP array with a locale setting? This is the setup: I am making an interactive sorted list in PHP. By user input, one of a number of categories (columns) can be made to direct the sorting (name, residence, etc). This I…
danbae
  • 563
  • 2
  • 8
  • 22
3
votes
1 answer

Why functions from wctype.h do not work without setlocale()?

My setup: glibc 2.24, gcc 6.2.0, UTF-8 environment. Consider the following example: #include #include #include int main(void) { setlocale(LC_CTYPE, "en_US.UTF-8"); wchar_t wc = L'я'; /* 00000100 01001111 */ if…
Igor Liferenko
  • 1,499
  • 1
  • 13
  • 28
3
votes
1 answer

Create "values-en" folder dynamically in android

First of all sorry for my weak english. I was searching for how to change language of my android application. I found in lots of link saying that creating values-fr (for french), values-en (for english) etc and copying strings.xml file into those…
Hilal
  • 902
  • 2
  • 22
  • 47
3
votes
2 answers

setlocale raising errno while a non-NULL value is returned

Consider the following minimalistic code fragment: #include #include #include int main() { const char *locale = setlocale(LC_ALL, ""); if (errno == ENOENT) { printf("Locale %s unavailable.\n", locale ?…
Bass
  • 4,977
  • 2
  • 36
  • 82
3
votes
3 answers

Php: Change language in date/strftime/strtotime

I'm trying to get the output on my second piece of code to be Dutch. The first code gives the right output, but in English. I tried to get it in Dutch but usually i ended up with 01-01-1970, 12-12-2015 or nothing. The code should give next friday…
JeroenM
  • 807
  • 1
  • 11
  • 26
3
votes
2 answers

How to set a Locale in Java Web application?

I am passing language code and country code from UI to create Locale object. How to set this Locale object in HttpServletRequest, so that any where in the web application I can this Locale object by using HttpServletRequest.getLocale()?
Mayank Gupta
  • 31
  • 1
  • 2
3
votes
3 answers

Windows Python: Changing encoding using the locale module

Using Python 2.7 I am writing an abstract web scraper and am having problems when displaying (printing) certain characters. I get the trace-back error: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2606' in position 5: ordinal not in…
Brandon Nadeau
  • 3,568
  • 13
  • 42
  • 65
3
votes
3 answers

Name of day/month that's not today in another language in php

Im trying to get the name of a day in php in another language than English. I changed the locale settings to setlocale(LC_ALL, 'nl_NL'); (this returns true) but the date still shows in English. I then found out you should use strftime() for it to…
user2729072
  • 33
  • 1
  • 3
3
votes
1 answer

How to enable two locales at once with #pragma in Visual C++?

As far as I know you can set your language with: #pragma setlocale("language") However you can only set it to one language. Anyone knows how to enable two languages in the same form in C++? Lithuanian and Russian in this case.
Matt
  • 33
  • 5
3
votes
1 answer

Smarty gettext localization

I am having trouble using gettext. This is how I set locale: $lang = 'romanian'; putenv("LANG=$lang"); $smarty->assign('lang',$lang); setlocale(LC_ALL, $lang); if (setlocale(LC_ALL, $lang)==false) print ' false'; else print…
2
votes
1 answer

How to make RRDtool use commas instead of dots as decimal separators in graphs

I'm using RRDtool through a Perl script (RRDs) to visualize temperature readings. As I want everything in the graph to be shown in Swedish (weekdays etc), I set the locale to sv_SE.UTF-8 in my Perl script with: use POSIX…
John V.
  • 45
  • 5
2
votes
1 answer

Alert Dialog not Change when selection

I'm trying to make multiple-choice language on my application. The language change when I selected it, but the selection not change. I use two languages, If I chose the first language (Indonesia) change, but if I chose the second language (English)…
Riken
  • 47
  • 8
2
votes
1 answer

newbie: help using mod_rewrite for localised website

Newbie: help switching locale with JSF Hi, I hope someone can help, I am having problems switching between locales in particular en_GB to en_US and en_US to en_GB for my website, however all other two character locales are switching…
disswade
  • 23
  • 2
2
votes
2 answers

How to use multiple sort_flags in PHP array sorting (Using SORT_LOCALE_STRING , SORT_NATURAL)?

How to use multiple sort_flags in PHP array sorting (Using SORT_LOCALE_STRING , SORT_NATURAL)? I want to using SORT_LOCALE_STRING for UTF8 languages + SORT_NATURAL Numbers. I want to Sort the following array: $array=array('Alpha', 'Älpha1',…
Alex
  • 299
  • 1
  • 8