Lines Matching refs:code
349 def _replace_encoding(code, encoding):
350 if '.' in code:
351 langname = code[:code.index('.')]
353 langname = code
367 """ Returns a normalized locale code for the given locale
370 The returned locale code is formatted for use with
377 the default encoding for the locale code just like setlocale()
384 code = localename.translate(_ascii_lower_map)
385 if ':' in code:
387 code = code.replace(':', '.')
388 if '@' in code:
389 code, modifier = code.split('@', 1)
392 if '.' in code:
393 langname, encoding = code.split('.')[:2]
395 langname = code
407 code = locale_alias.get(lookup_name, None)
408 if code is not None:
409 return code
414 code = locale_alias.get(lang_enc, None)
415 if code is not None:
417 if '@' not in code:
418 return code + '@' + modifier
419 if code.split('@', 1)[1].translate(_ascii_lower_map) == modifier:
420 return code
428 code = locale_alias.get(lookup_name, None)
429 if code is not None:
431 if '@' not in code:
432 return _replace_encoding(code, encoding)
433 code, modifier = code.split('@', 1)
434 return _replace_encoding(code, encoding) + '@' + modifier
438 code = locale_alias.get(langname, None)
439 if code is not None:
441 if '@' not in code:
442 return _replace_encoding(code, encoding) + '@' + modifier
443 code, defmod = code.split('@', 1)
445 return _replace_encoding(code, encoding) + '@' + defmod
451 """ Parses the locale code for localename and returns the
452 result as tuple (language code, encoding).
458 The language code corresponds to RFC 1766. code and encoding
463 code = normalize(localename)
464 if '@' in code:
466 code, modifier = code.split('@', 1)
467 if modifier == 'euro' and '.' not in code:
471 return code, 'iso-8859-15'
473 if '.' in code:
474 return tuple(code.split('.')[:2])
475 elif code == 'C':
481 """ Builds a locale code from the given tuple (language code,
498 them as tuple (language code, encoding).
513 Except for the code 'C', the language code corresponds to RFC
514 1766. code and encoding can be None in case the values cannot
522 code, encoding = _locale._getdefaultlocale()
526 # make sure the code/encoding values are valid
527 if sys.platform == "win32" and code and code[:2] == "0x":
529 code = windows_locale.get(int(code, 0))
532 return code, encoding
551 tuple (language code, encoding).
556 Except for the code 'C', the language code corresponds to RFC
557 1766. code and encoding can be None in case the values cannot
569 a string, an iterable of two strings (language code and encoding),
594 # On Win32, this will return the ANSI code page
1776 # locale code.