locale

Difference in performance between calling .localeCompare on string objects and constructing a purpose-made Intl.Collator object?

荒凉一梦 提交于 2019-12-11 03:11:33
问题 Background: So I need to sort lots of strings. Arrays of strings, actually, but that's besides the point. What isn't is that I need to implement my own sorter function, as detailed in the linked question.Performance is quite important to me. jFriend00 very helpfully suggested that I use String.prototype.localeCompare . The arrays I'm sorting are 100K+ elements long, and so performance is pretty important. On the MDN doc for .localeCompare, under Performance , it says: When comparing large

How to return records in correct order in PostgreSQL

帅比萌擦擦* 提交于 2019-12-11 02:29:50
问题 Query select 'T' union all select 'Z' order by 1 returns Z T but correct order should be T Z Tried in 3 different OSes Windows 2003 server "PostgreSQL 9.1.3, compiled by Visual C++ build 1500, 32-bit" Windows 7 "PostgreSQL 9.2.1, compiled by Visual C++ build 1600, 32-bit" Debian "PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 64-bit" Database settings are: Collation: et_EE.UTF-8 Character type: et_EE.UTF-8 How to fix this? Update Databases were

Reading in Russian characters (Unicode) using a basic_ifstream<wchar_t>

最后都变了- 提交于 2019-12-11 02:24:45
问题 Is this even possible? I've been trying to read a simple file that contains Russian, and it's clearly not working. I've called file.imbue(loc) (and at this point, loc is correct, Russian_Russia.1251). And buf is of type basic_string<wchar_t> The reason I'm using basic_ifstream<wchar_t> is because this is a template (so technically, basic_ifstream<T>, but in this case, T=wchar_t). This all works perfectly with english characters... while (file >> ch) { if(isalnum(ch, loc)) { buf += ch; } else

How to ensure english error messages in testthat unit tests

与世无争的帅哥 提交于 2019-12-11 02:13:07
问题 I have a lot of unit tests using the testthat package that expect english error messages. If other developer run the tests on a computer configured for a non-english locale the error message are emitted in a different language and my tests fail. How can I initialize testthat to change the language settings only during the test run-time without manually or permanently changing the language or test environment from outside of R (like e. g. proposed here: in R how to get error messages in

User locale does not work at first request

帅比萌擦擦* 提交于 2019-12-11 01:56:18
问题 My website is running Symfony, master version. So far, I was able to use the LocalListener logic from the website, with a slight difference due to code not being compatible with my version. (I think) I only simplified the onKernelRequest method this way: public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if (!$request->hasPreviousSession()) { return; } if ($locale = $request->get('_locale')) { $request->getSession()->set('_locale', $locale); } $request

What is the correct way to get a LOCALE_SSHORTDATE that is guaranteed to have a full (4-digit) year number?

一笑奈何 提交于 2019-12-11 01:53:37
问题 I want to create a date-time picker control that shows both date and time, as a combination of the DTS_SHORTDATECENTURYFORMAT and DTS_TIMEFORMAT styles. Since there is no such style built into the date-time picker, I have to do it myself with GetLocaleInfoEx() . I notice that by default, GetLocaleInfoEx(LOCALE_SSHORTDATE) seems to return a four-digit year, which is what I want. Is this reliable? It's not documented anywhere, only that there can be more than one string for LOCALE_SSHORTDATE .

Javascript Date Parse with specific locale

ε祈祈猫儿з 提交于 2019-12-11 01:46:33
问题 I receive date/time objects from user input, and would like to parse them to a javascript Date object. The date is in the format: 02/06/2018 00:59:03 which means second of june, 2018; UK locale. Although this seems extremely trivial and a super wide use case scenario, I can't seem to find anything in the documentation how to specify the locale I wish to use for parsing. What the parser does is simply assume I am using US locale format, which defaults to having first the month, then the day,

Why isn't QString::localeAwareCompare() working correctly

别来无恙 提交于 2019-12-11 01:15:17
问题 A Finnish customer tells me that the correct (locale aware) sorting for Finnish is: a-z, å, ä, ö. But QString::localeAwareCompare() returns it as: a, ä, å, b-o, ö, p-z in Qt 4.4.2 on Windows Vista. #include <qapplication.h> #include <qlocale.h> #include <iostream> #include <tchar.h> int main( int argc, char* argv[] ) { QLocale::setDefault ( QLocale( QLocale::Finnish ) ); QApplication app( argc, argv ); QString s1 = "a"; QString s2 = "ä"; QString s3 = "å"; QString s4 = "b"; QString s5 = "o";

android Locale.Builder() doesn't mirror the page in right-to-left locales

懵懂的女人 提交于 2019-12-11 01:00:56
问题 When I use locale = new Locale("ar"); the screen is mirrored in the right way. In order to give the option to set the numeric system, i have to use the Locale.Builder() inserted with lollipop. locale = new Locale.Builder().setLanguage("ar").setRegion("MA").setExtension(Locale.UNICODE_LOCALE_EXTENSION, "nu-latn").build(); The problem is that in this way the screen is not mirrored properly. There is a way, like an Extension, to set the rtl attribute? 回答1: SOLUTION: In order to mirror the screen

Langinfo.h in Visual Studio 2010

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 00:57:27
问题 How can I include into my Visual Studio 2010 C-project langinfo.h. I've tried #include <langinfo.h> , but it seems there is no such header file in the VS 2010 environment. I need to get the starting weekday for the locale, but I now the way only using this library. So, the question is how to solve my problem: how to include langinfo.h, or how to get the current locale starting weekday. 回答1: I think, you should use GetLocaleInfoEx() function. For example, to get the starting day of a week