Skip to content

Instantly share code, notes, and snippets.

@hlassiege
Last active May 3, 2018 08:56
Show Gist options
  • Save hlassiege/bc14e4cbbb86f5ca6cf4535ea74c73c0 to your computer and use it in GitHub Desktop.
Save hlassiege/bc14e4cbbb86f5ca6cf4535ea74c73c0 to your computer and use it in GitHub Desktop.
unicode python 2.x
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; CharSet=UTF8;
$number = 1234.56;
// Notation anglaise (par défaut)
$english_format_number = number_format($number);
// 1,235 Notation française
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
import locale
import datetime
locale.setlocale( locale.LC_ALL, 'en_US' )
// va afficher : '$188518982.18'
locale.currency( 188518982.18 )
// va afficher '1,255,000'
locale.format("%d", 1255000, grouping=True)
// va afficher '12/13/2011 12:00:00 AM'
today=datetime.date.today()
today.strftime('%c')
CultureInfo ci = CultureInfo.CurrentCulture;
string money = 120.ToString(“c”,ci);
string myDate = DateTime.Now.ToString(ci);
require_once 'I18Nv2.php';
$locale = &I18Nv2::createLocale('en_US');
echo "Format a currency value of 2000: ",
$locale->formatCurrency(2000, I18Nv2_CURRENCY_INTERNATIONAL), "\n";
echo "Format todays date:              ",
$locale->formatDate(null, I18Nv2_DATETIME_FULL), "\n";
echo "Format number :              ",
$locale->formatNumber(1234.56), "\n";
Culture culture = CultureInfo.CurrentCulture ;
locale_get_default()
// ou
Locale::getDefault()
l = locale.getdefaultlocale()
ResourceBundle rb = ResourceBundle.getBundle("myBundle", currentLocale);
String message = rb.getString("string1");
$rb = new ResourceBundle('root', "./locale");
echo resourcebundle_get($rb, 'string1');
ou
echo $r->get('string1');
import gettext
print _("Hello, World!")
unicodeString = u"hello Unicode world!"
$utf8key = utf8_encode($key);
...
$len = mb_strlen($utf8key, 'utf-8');
ou
$len = mb_strlen($utf8key);  // si l’encodage a été correctement paramétré pour le module mbstring
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
ou en HTML5
<meta charset="UTF-8">
<p dir="LTR">שלם</p>
<p dir="RTL">שלם</p>
jdbc:mysql://localhost/some_db?useUnicode=yes&characterEncoding=UTF-8
mysql_connect("serveur","login","pass");
mysql_select_db("myDbUtf8");
mysql_query("SET NAMES 'utf8'");
import MySQLdb
db = MySQLdb.connect(host=DB_HOST ,user=DB_USER ,passwd=DB_PASS,db=DB_NAME, charset = "utf8", use_unicode = True)
NumberFormat nf = NumberFormat.getInstance(); // pour utiliser la Locale courante
ou
NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH); // pour spécifier une Locale
myNumber = nf.parse(myString);
NumberFormat nf   = NumberFormat.getCurrencyInstance();
nf.format(1234.56);
DateFormat df = DateFormat.getDateInstance();
myDate = df.parse(myString);
<? header('Content-Type: text/html; charset=utf-8'); ?>
echo $myTransations[‘string1’];
require_once 'langs/'.$lang.'.php';
<?xml version="1.0" encoding="UTF-8"?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment