setlocale

Sorting PHP array with locale setting?

帅比萌擦擦* 提交于 2021-02-16 20:17:55
问题 Is it possible to sort a PHP array with a locale setting? This is the setup: I am making an interactive sorted list in PHP. By user input, one of a number of categories (columns) can be made to direct the sorting (name, residence, etc). This I worked out by using array_multisort() function. Next hurdle. The list is in Swedish and the user will expect Swedish alphabetical order: abcdefghijklmnopqrstuvxyzåäö. Right now the interpreter sorts åäö as non-alphabetical and places them before "a".

Sorting PHP array with locale setting?

强颜欢笑 提交于 2021-02-16 20:16:31
问题 Is it possible to sort a PHP array with a locale setting? This is the setup: I am making an interactive sorted list in PHP. By user input, one of a number of categories (columns) can be made to direct the sorting (name, residence, etc). This I worked out by using array_multisort() function. Next hurdle. The list is in Swedish and the user will expect Swedish alphabetical order: abcdefghijklmnopqrstuvxyzåäö. Right now the interpreter sorts åäö as non-alphabetical and places them before "a".

Laravel APP_LOCALE in spanish

為{幸葍}努か 提交于 2021-02-05 10:54:29
问题 In Laravel 5.4, in .env I have: APP_LOCALE=es APP_FALLBACK_LOCALE=en APP_LOCALE_PHP=es_US and in config/app.php : 'locale' => env('APP_LOCALE', 'es'), 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), 'locale_php' => env('APP_LOCALE_PHP', 'en_US'), But I want to set as spanish. For example, In a controller I have: $mydate = date('d F Y', strtotime($data->created)); $data->created is a string that comes from database, from column created_at . This way it show as: 14 August 2017 English,

How to use PHP Locale functions

我们两清 提交于 2021-01-28 05:51:39
问题 I'm running PHP on windows vista . So, I'm trying to get to know how locale functions work. I started with setlocale(LC_ALL, $locale) and localeconv() At first it worked with CLDR locale IDs(I think.., Just started learning PHP locales) like "en_US", "en_UK", etc, resulting as demonstrated in the PHP documentation examples. But now setlocale() and localeconv() only works with $locale values like "English_United Kingdom.1252" and "English_United States.1252" which I believe is windows based

Windows Python: Changing encoding using the locale module

你说的曾经没有我的故事 提交于 2021-01-27 12:41:40
问题 Using Python 2.7 I am writing an abstract web scraper and am having problems when displaying (printing) certain characters. I get the trace-back error: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2606' in position 5: ordinal not in range(128) from printing the string containing the character. I used the locale module to find out my OS supported settings, although I'm not certain I should use locale for my problem, and noticed the default settings where (en_US', 'cp1252') . I

Windows Python: Changing encoding using the locale module

陌路散爱 提交于 2021-01-27 12:40:50
问题 Using Python 2.7 I am writing an abstract web scraper and am having problems when displaying (printing) certain characters. I get the trace-back error: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2606' in position 5: ordinal not in range(128) from printing the string containing the character. I used the locale module to find out my OS supported settings, although I'm not certain I should use locale for my problem, and noticed the default settings where (en_US', 'cp1252') . I

What is setlocale() for?

做~自己de王妃 提交于 2020-07-22 18:16:31
问题 I'm studying c++ and I have found this function of C++ library: setlocale (http://www.cplusplus.com/reference/clocale/setlocale/) but I'm not able to understand what is it for. I have used on Ubuntu: printf ("Locale is: %s\n", setlocale(LC_ALL,"") ); it prints Locale is: en_US.UTF-8 but on macOs it prints: Locale is: C what does means this C? In what context and how should it be used? 回答1: Read on Linux the setlocale(3) and locale(7) man pages. Read also the internationalization and

What is setlocale() for?

ぃ、小莉子 提交于 2020-07-22 18:16:12
问题 I'm studying c++ and I have found this function of C++ library: setlocale (http://www.cplusplus.com/reference/clocale/setlocale/) but I'm not able to understand what is it for. I have used on Ubuntu: printf ("Locale is: %s\n", setlocale(LC_ALL,"") ); it prints Locale is: en_US.UTF-8 but on macOs it prints: Locale is: C what does means this C? In what context and how should it be used? 回答1: Read on Linux the setlocale(3) and locale(7) man pages. Read also the internationalization and

PHP: date “F” with setlocale not working

和自甴很熟 提交于 2019-12-23 12:00:00
问题 <ul> <?php $event_date = get_sub_field('event_date'); // 20150203 $event_date_format = DateTime::createFromFormat('Ymd', $event_date); setlocale(LC_ALL, 'de_DE'); ?> <li> <h6><?php echo $event_date_format->format('d');?>. <?php echo $event_date_format->format('F');?></h6> <p><?php echo $event_date_format->format('H');?>:<?php echo $event_date_format->format('i');?></p> </li> </ul> The output of this is 03. February 19:25 Why does setlocale not have any impact on this. I want my Month "F" to

PHP iconv greek/cyrillic transliteration does not work

↘锁芯ラ 提交于 2019-12-22 09:07:42
问题 i have the following test code: setlocale(LC_ALL, 'en_US.UTF8'); function t($text) { echo "$text\n"; echo "encoding: ", mb_detect_encoding($text), "\n"; // transliterate $text = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $text); echo "iconv: ", $text, "\n"; } // Latvian alphabet t('AĀBCČDEĒFGĢHIĪJKĶLĻMNŅOPRSŠTUŪVZŽ aābcčdeēfgģhiījkķlļmnņoprsštuūvzž'); // Greek alphabet t('ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω'); // Cyrillic alphabet + some rarer versions t(