Lines Matching refs:code

362 def _replace_encoding(code, encoding):
363 if '.' in code:
364 langname = code[:code.index('.')]
366 langname = code
385 def _append_modifier(code, modifier):
387 if '.' not in code:
388 return code + '.ISO8859-15'
389 _, _, encoding = code.partition('.')
391 return code
393 return _replace_encoding(code, 'ISO8859-15')
394 return code + '@' + modifier
398 """ Returns a normalized locale code for the given locale
401 The returned locale code is formatted for use with
408 the default encoding for the locale code just like setlocale()
413 code = localename.lower()
414 if ':' in code:
416 code = code.replace(':', '.')
417 if '@' in code:
418 code, modifier = code.split('@', 1)
421 if '.' in code:
422 langname, encoding = code.split('.')[:2]
424 langname = code
436 code = locale_alias.get(lookup_name, None)
437 if code is not None:
438 return code
443 code = locale_alias.get(lang_enc, None)
444 if code is not None:
446 if '@' not in code:
447 return _append_modifier(code, modifier)
448 if code.split('@', 1)[1].lower() == modifier:
449 return code
457 code = locale_alias.get(lookup_name, None)
458 if code is not None:
460 if '@' not in code:
461 return _replace_encoding(code, encoding)
462 code, modifier = code.split('@', 1)
463 return _replace_encoding(code, encoding) + '@' + modifier
467 code = locale_alias.get(langname, None)
468 if code is not None:
470 if '@' not in code:
471 code = _replace_encoding(code, encoding)
472 return _append_modifier(code, modifier)
473 code, defmod = code.split('@', 1)
475 return _replace_encoding(code, encoding) + '@' + defmod
481 """ Parses the locale code for localename and returns the
482 result as tuple (language code, encoding).
488 The language code corresponds to RFC 1766. code and encoding
493 code = normalize(localename)
494 if '@' in code:
496 code, modifier = code.split('@', 1)
497 if modifier == 'euro' and '.' not in code:
501 return code, 'iso-8859-15'
503 if '.' in code:
504 return tuple(code.split('.')[:2])
505 elif code == 'C':
507 elif code == 'UTF-8':
515 """ Builds a locale code from the given tuple (language code,
532 'two strings -- language code, encoding.') from None
537 them as tuple (language code, encoding).
552 Except for the code 'C', the language code corresponds to RFC
553 1766. code and encoding can be None in case the values cannot
567 code, encoding = _locale._getdefaultlocale()
571 # make sure the code/encoding values are valid
572 if sys.platform == "win32" and code and code[:2] == "0x":
574 code = windows_locale.get(int(code, 0))
577 return code, encoding
596 tuple (language code, encoding).
601 Except for the code 'C', the language code corresponds to RFC
602 1766. code and encoding can be None in case the values cannot
614 a string, an iterable of two strings (language code and encoding),
1501 # locale code.