locale

Linux & C-Programming: How can I write utf-8 encoded text to a file?

元气小坏坏 提交于 2019-12-11 06:55:13
问题 I am interested in writing utf-8 encoded strings to a file. I did this with low level functions open() and write(). In the first place I set the locale to a utf-8 aware character set with setlocale("LC_ALL", "de_DE.utf8") . But the resulting file does not contain utf-8 characters, only iso8859 encoded umlauts. What am I doing wrong? Addendum: I don't know if my strings are really utf-8 encoded in the first place. I just keep them in the source file in this form: char *msg = "Rote Grütze"; See

Routes: can't get default scope(:locale) to work with user_path(id), always have to submit locale explicitly

主宰稳场 提交于 2019-12-11 06:55:05
问题 I've done some research on this topic already, but I don't seem to be able to figure it out. I have followed the official guide to set up I18n, but I just don't get the default locale to be set properly (when no explicit locale is specified). # routes.rb require 'sidekiq/web' Iq::Application.routes.draw do scope "(:locale)", locale: /de|en/ do # ... end end # application_controller.rb class ApplicationController < ActionController::Base before_filter :set_language def set_language I18n.locale

Translate country name into other language

懵懂的女人 提交于 2019-12-11 05:39:41
问题 I searched for a solution, but I have not found any. I have this kind of information: String locale = "en_GB"; String country = "Japonia"; //It means Japan in polish I need to translate the country name "Japonia" into language indicated in string locale, so "Japan". Is there any way to do it? 回答1: Assuming you know both the input language and the desired output language, an alternative approach - iterate the Locale (s) on the system using Locale.getAvailableLocales(), test if the country name

Unexpected behavior of Sys.setlocale

混江龙づ霸主 提交于 2019-12-11 05:18:33
问题 Please see the code below, I have to change my locale to be able to convert a date. My first attempt is unsuccessful, my second attempt works, though it seems redundant and doesn't change the output of Sys.getlocale . My OS is Windows 7 64-bit Sys.getlocale() # "LC_COLLATE=French_Belgium.1252;LC_CTYPE=French_Belgium.1252;LC_MONETARY=French_Belgium.1252;LC_NUMERIC=C;LC_TIME=French_Belgium.1252" date <- "Dec-11" as.Date(date, format = "%b-%d") # NA Sys.setlocale(locale = "UK") # "LC_COLLATE

PHP setlocale() not working for ctype_alpha check

╄→尐↘猪︶ㄣ 提交于 2019-12-11 05:07:26
问题 I run this php code: echo "<br>system locales: ".system('locale -a')."<br><br>"; echo "current locales: ".setlocale(LC_ALL, 0)."<br><br>"; var_dump(setlocale (LC_ALL, 'de_DE.utf8')); echo "current locales: ".setlocale(LC_ALL, 0)."<br><br>"; echo "accepting german characters?: ".ctype_alpha("äüöß")."<br><br>"; echo "accepting characters in general?: ".ctype_alpha("test")."<br><br>"; echo "rejecting numbers?: ".ctype_alpha("tes2t")."<br><br>"; and get this output: C C.UTF-8 POSIX de_DE.utf8

Change Ubuntu locale in Docker

三世轮回 提交于 2019-12-11 04:06:42
问题 So I'm setting up a docker image with Ubuntu and Postgresql in pt_BR and I'd like to know how can I change the default locale via command line without restarting the system - which is not possible in a Docker build :). I managed to do it in Debian by changing setting LANG,LANGUAGE and LC_* variables in /etc/default/locale , modifying /etc/locale.gen and running dpkg-reconfigure , as shown here. In Ubuntu it doesn't work. 回答1: It should work with Ubuntu similarly. A sample Dockerfile FROM

symfony 2 how to make numbers appear in western arabic

谁说胖子不能爱 提交于 2019-12-11 03:54:11
问题 i am making an arabic website with symfony2 ! when i set the locale as "ar" for arabic, even numbers are converted in arabic ! Western Arabic 0 1 2 3 4 5 6 7 8 9 became: Eastern Arabic ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ is there a solution to make the numbers appears in the wester form ? thank you ! 回答1: <?php /** * Converts numbers in string from western to eastern Arabic numerals. * * @param string $str Arbitrary text * @return string Text with western Arabic numerals converted into eastern Arabic

SimpleDateFormat Unparseable date Error if locale is ES. Twitter “Created_At”

好久不见. 提交于 2019-12-11 03:45:12
问题 I'm trying to convert the twitter "created_at" to an Argentinian Date-time. If I do this: final String TWITTER="EEE MMM dd HH:mm:ss"; SimpleDateFormat sf = new SimpleDateFormat(TWITTER,new Locale("en")); It works fine. But if I change to Locale("es") , Locale("es","ES") or Locale("es","AR") , I am getting this error: 07-01 11:09:29.153: W/System.err(331): java.text.ParseException: Unparseable date: "Tue Jul 01 13:57:36 +0000 2014" Why can't I convert the date to my local time? EDIT: Based on

Get ONLY the list of locales that are shipped with my Android applicaiton

淺唱寂寞╮ 提交于 2019-12-11 03:32:59
问题 I know there are several ways that I can get the list of all of the Locales supported by the device. Has anyone been able to get the list of locales that you have included in your app? Using the following code I know I can get the list the device supports: String[] languages = getAssets().getLocales(); or String[] languages = Resources.getSystem().getAssets().getLocales(); But I want the list that is shipped w/ my app so i can compare it against the list that the phone supports to create a

Android changing language configuration messes up layout

纵饮孤独 提交于 2019-12-11 03:13:02
问题 So I'm trying to add hebrew support to my android app. I had to change the version to 2.2 so it would have built-in hebrew fonts. Some things in the layout has messed up but I fixed them. But one thing has left - for some reason, when forcing hebrew locale, ONE of my layouts gets messed up... No idea why. And even when using the SAME layout for both locales (English and Hebrew) it's still get messed up this way (But the texts still stick to the left) Here is the normal layout (Graph is taking