C programming: How can I program for Unicode?

C99 or earlier The C standard (C99) provides for wide characters and multi-byte characters, but since there is no guarantee about what those wide characters can hold, their value is somewhat limited. For a given implementation, they provide useful support, but if your code must be able to move between implementations, there is insufficient guarantee … Read more

With a browser, how do I know which decimal separator the operating system uses?

Here is a simple JavaScript function that will return this information. Tested in Firefox, IE6, and IE7. I had to close and restart my browser in between every change to the setting under Control Panel / Regional and Language Options / Regional Options / Customize. However, it picked up not only the comma and period, … Read more

Retrieve a list of countries from the android OS

You might get some idea from the Locale class. Call getAvailableLocales() then iterate the array & getDisplayCountry(). If it is the first time you’ve seen that country name, add it to an expandable list (e.g. an ArrayList instance). E.G. In Java, but the 3 classes from java.util are all available in Android. import java.util.*; class … Read more

How do I change the locale that JasperReports uses?

The locale is set during execution, not in the JRXML. Using Java, set the REPORT_LOCALE parameter for the report’s parameter map. For example: InputStream reportTemplate = getReportTemplate(); JRDataSource dataSource = getDataSource(); java.util.Map parameters = getParameters(); java.util.Locale locale = new Locale( “en”, “US” ); parameters.put( JRParameter.REPORT_LOCALE, locale ); JasperFillManager.fillReport( reportTemplate, parameters, dataSource ); Using Jaspersoft Studio, … Read more

Time zone issue involving date fns format()

You will need to subtract the time zone offset of your local time zone from the Date instance, before you pass it to format from date-fns. For example: const dt = new Date(‘2017-12-12’); const dtDateOnly = new Date(dt.valueOf() + dt.getTimezoneOffset() * 60 * 1000); console.log(format(dtDateOnly, ‘YYYY-MM-DD’)); // Always “2017-12-12” Problem You want to handle only … Read more

How do I strftime a date object in a different locale? [duplicate]

The example given by Rob is great, but isn’t threadsafe. Here’s a version that works with threads: import locale import threading from datetime import datetime from contextlib import contextmanager LOCALE_LOCK = threading.Lock() @contextmanager def setlocale(name): with LOCALE_LOCK: saved = locale.setlocale(locale.LC_ALL) try: yield locale.setlocale(locale.LC_ALL, name) finally: locale.setlocale(locale.LC_ALL, saved) # Let’s set a non-US locale locale.setlocale(locale.LC_ALL, ‘de_DE.UTF-8’) … Read more

IPython Notebook locale error [duplicate]

I summarize here the solution to be found on: http://blog.lobraun.de/2009/04/11/mercurial-on-mac-os-x-valueerror-unknown-locale-utf-8/ I added these lines to my .bash_profile: export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 I reloaded the profile: source ~/.bash_profile I then ran ipython again: ipython notebook Changing locales The above will work for the English language in a US locale. One may want different settings. At the … Read more