locale

xlocale broken on OS X?

末鹿安然 提交于 2019-12-21 17:36:03
问题 I have a simple program that tests converting between wchar_t and char using a series of locales passed to it on the command line. It outputs a list of the conversions that fail by printing out the locale name and the string that failed to convert. I'm building it using clang and libc++. My understanding is that libc++'s named locale support is provided by the xlocale library on OS X. I'm seeing some unexpected failures, as well as some instances where conversion should fail, but doesn't.

Swift 3 and NumberFormatter (.currency) == ¤?

强颜欢笑 提交于 2019-12-21 11:07:28
问题 Xcode 8.0 (8A218a) GM Target : iOS 10 (Swift 3) Consider the following code: let number = NSDecimalNumber(decimal: 22.4) let numberFormatter = NumberFormatter() numberFormatter.numberStyle = .currency numberFormatter.locale = Locale.current let result = numberFormatter.string(from: number) print(result!) The result is: ¤22.40 (I have no idea what ¤ means.) But if I initialize the locale such as: numberFormatter.locale = Locale(identifier: "en_US") The result will be: $22.40 ... which is what

How to format the Spanish month in sentence case using SimpleDateFormat?

余生颓废 提交于 2019-12-21 10:56:07
问题 This is my code : /* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.text.SimpleDateFormat; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { SimpleDateFormat date = new SimpleDateFormat("dd-MMM-yyyy", new Locale("es","ar")); System.out.println(date.format(new Date(2014-1900,0,1))); } } The above code returns, 01-ene

Postgres locale error

醉酒当歌 提交于 2019-12-21 07:12:54
问题 I have a Postgres database hosted on Digital River, on Ubuntu, and followed these instructions to install: But something is wrong with the locale settings and I cannot work out how to fix it. When I run the psql command I get the following error: postgres@assay:/home/deployer$ psql perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US:en", LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and installed on your

Locale based sort in Javascript, sort accented letters and other variants in a predefined way

强颜欢笑 提交于 2019-12-21 07:12:01
问题 In Finnish we sort W after V (as in English) but because W is not a native Finnish letter, it is considered as a variant of V , which is sorted as it were equal to V , but in cases where the only difference between two words is that V is W , then V -version is sorted first. An example enlights the proper order: Vatanen, Watanen, Virtanen In Finnish V and W are collated as A and Á . Á is sorted like A , but in cases where it is the only difference, the unaccented one comes first. The same rule

Difference between toLocaleLowerCase() and toLowerCase() [duplicate]

风流意气都作罢 提交于 2019-12-21 06:47:33
问题 This question already has answers here : In what JS engines, specifically, are toLowerCase & toUpperCase locale-sensitive? (2 answers) Closed 4 years ago . I was trying to fiddle with toLocaleLowerCase() and toLowerCase() methods. function ByLocale() { document.getElementById("demo").innerText.toLocaleLowerCase(); } function ByLower() { document.getElementById("demo").innerText.toLowerCase(); } <p>Click the button to convert the string "HELLO World!" to lowercase letters.</p> <button onclick=

Setting Locale Programmatically not working?

做~自己de王妃 提交于 2019-12-21 05:04:12
问题 I have an activity where I programmatically set the locale to "de" and it doesn't work as expected and displays the default language (English text) that is manually set. Please help public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Programmatically sets the locale and language Locale locale = new Locale("de"); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration

Why does Locale.getDefault().getLanguage() in Android return the display name instead of the language code?

这一生的挚爱 提交于 2019-12-21 03:57:08
问题 According to the Java reference, Locale.getLanguage() is supposed to return the 2-letters lowercase ISO code of the language (e.g. en ), while getDisplayLanguage() is the method for obtaining the readable name (e.g. English ). So how comes that the following code in Android: Locale.getDefault().getLanguage() returns English or Español instead of en and es ???? I'm completely puzzled... 回答1: Use getResources().getConfiguration().locale.getLanguage() and it will work just fine even though I

How does tokenization and pattern matching work in Chinese.?

╄→尐↘猪︶ㄣ 提交于 2019-12-21 03:56:05
问题 This question involves computing as well as knowledge of Chinese. I have chinese queries and I have a separate list of phrases in Chinese I need to be able to find which of these queries have any of these phrases. In english, it is a very simple task. I don't understand Chinese at all, its semantics, grammar rules etc. and if somebody in this forum who also understands Chinese can help me with some basic understanding and how pattern matching is done for Chinese. I have a basic perception

Get country name from country code

依然范特西╮ 提交于 2019-12-21 03:13:10
问题 I'd need to get the full country name from the country code. For example for Netherlands, I'd need the Netherlands from the country code NL . I thought I could do that with Locale like: Locale loc = new Locale("NL"); loc.getCountry(); but loc.getCountry(); is empty. Any idea about how to do this, please? Thanks in advance! 回答1: try like this Locale loc = new Locale("","NL"); loc.getDisplayCountry(); Hope this will help out. 回答2: This should work: Locale l = new Locale("", "NL"); String