locale

How to read Cyrillic Unicode file in C++?

拈花ヽ惹草 提交于 2020-01-02 04:12:10
问题 I'm trying to read lines from .txt files, that have been saved as Unicode. That's how i'm doing it: wifstream input; string path = "test.txt"; input.imbue(locale(input.getloc(), new codecvt_utf16<wchar_t, 0x10ffff, consume_header>)); input.open(path); if (input.is_open()) { wstring line; input.seekg( 1 , ios_base::beg); getline(input, line); } It works fine for files with Latin characters. But for Cyrillic files I get weird symbols instead of spaces and adjacent characters. For example: What

Changing the “locale preferred encoding”

一个人想着一个人 提交于 2020-01-02 02:55:30
问题 [Using Python 3.2] If I don't provide encoding argument to open , the file is opened using locale.getpreferredencoding() . So for example, on my Windows machine, any time I use open('abc.txt') , it would be decoded using cp1252 . I would like to switch all my input files to utf-8 . Obviously, I can add encoding = 'utf-8' to all my open function calls. Or, better, encoding = MY_PROJECT_DEFAULT_ENCODING , where the constant is defined at the global level somewhere. But I was wondering if there

How to get list of locales in .Net

ε祈祈猫儿з 提交于 2020-01-02 02:21:11
问题 I would like to give user option to select text file locale. Is there some class in .net that keeps list of available locales? Now, I am planning to make my own list class from MSDN page: Language Identifier Constants and Strings, but it would be nicer if there is something already in .net. Here is MSDN article on CultureInfo.GetCultures method that Jeremy wrote in his answer. There are also code examples. 回答1: You'd want like a 'for each locale loop'. Dim info As CultureInfo For Each info In

Elegant way to get Locale in Spring Controller [duplicate]

一世执手 提交于 2020-01-02 01:07:12
问题 This question already has an answer here : Finding Locale from Controller in Spring MVC (1 answer) Closed last year . I'm looking for a cleaner way (in Spring 3.2) to get the current locale than explicitly calling LocaleContextHolder.getLocale() at the start of each Controller method. It has to be compatible with Java annotation, as I'm not using the XML config. Here's what I'm doing currently. @Controller public class WifeController { @Autowired private MessageSource msgSrc; @RequestMapping

How do I change the currency symbol in Magento 1.5.1.0?

妖精的绣舞 提交于 2020-01-01 19:34:49
问题 I'm trying to change the price format in Magento ver. 1.5.1.0 from €8.49 to EUR 8.49 I have been looking through lots of posts and forums but it didn't work out. I tried to follow the instructions but it didn't work out so far. Cache is deactivated. /lib/Zend/Locale/Data/en.xml <currency type="EUR"> <displayName>Euro</displayName> <displayName count="one">euro</displayName> <displayName count="other">euros</displayName> //added <symbol>EUR</symbol> here </currency> /lib/Zend/Locale/Data/root

How to support multiple language in a Linux C/C++ program?

大憨熊 提交于 2020-01-01 16:51:11
问题 For example, in this simplest hello world program: #include <iostream> int main() { std::cout<<"Hello World!"<<std::endl; return 0; } I'd like to see French if user's environment LANG is set to fr_FR , it might looks like: $ ./a.out Hello World! $ LANG=fr_FR.utf8 $ ./a.out Bonjour tout le monde! Is there a guideline of how to archieve this in Linux? 回答1: The key is to use "resources" (one per-language, configured to be read at runtime) vs. hard-coding strings. GUI frameworks like Qt and GTK+

How to support multiple language in a Linux C/C++ program?

和自甴很熟 提交于 2020-01-01 16:51:10
问题 For example, in this simplest hello world program: #include <iostream> int main() { std::cout<<"Hello World!"<<std::endl; return 0; } I'd like to see French if user's environment LANG is set to fr_FR , it might looks like: $ ./a.out Hello World! $ LANG=fr_FR.utf8 $ ./a.out Bonjour tout le monde! Is there a guideline of how to archieve this in Linux? 回答1: The key is to use "resources" (one per-language, configured to be read at runtime) vs. hard-coding strings. GUI frameworks like Qt and GTK+

C++ Error “failure: locale::facet::_S_create_c_locale name not valid” when running program from command line

帅比萌擦擦* 提交于 2020-01-01 11:52:08
问题 I seem to have a problem with locales in C++. When I run my programm from within Eclipse, it all works fine. However, when I try to run from the command line, I keep getting this error: failure: locale::facet::_S_create_c_locale name not valid This is the code that triggers the error: // Set up UTF8 file stream string fileName = "./sz.txt"; wifstream inFileStream; try { setlocale(LC_ALL, ""); inFileStream.open(fileName.c_str()); inFileStream.imbue(locale("")); if(!inFileStream) { return EXIT

Dynamic locale switching in a JSF app?

六月ゝ 毕业季﹏ 提交于 2020-01-01 11:48:11
问题 I have an application where the user can dynamically switch between locales from the welcome page of my application. I see that the earlier developer (inherited the code without much documentation) has overridden the following three methods from ViewHandler and tells me that this is required for dynamic switching of the Locale...any help is highly appreciated Also, do let me know if there is a better way of handling this public Locale calculateLocale(FacesContext facescontext) { Locale

Dynamic locale switching in a JSF app?

时间秒杀一切 提交于 2020-01-01 11:48:04
问题 I have an application where the user can dynamically switch between locales from the welcome page of my application. I see that the earlier developer (inherited the code without much documentation) has overridden the following three methods from ViewHandler and tells me that this is required for dynamic switching of the Locale...any help is highly appreciated Also, do let me know if there is a better way of handling this public Locale calculateLocale(FacesContext facescontext) { Locale