MCPcopy Index your code
hub / github.com/python/cpython / _replace_encoding

Function _replace_encoding

Lib/locale.py:352–373  ·  view source on GitHub ↗
(code, encoding)

Source from the content-addressed store, hash-verified

350_setlocale = setlocale
351
352def _replace_encoding(code, encoding):
353 if '.' in code:
354 langname = code[:code.index('.')]
355 else:
356 langname = code
357 # Convert the encoding to a C lib compatible encoding string
358 norm_encoding = encodings.normalize_encoding(encoding)
359 #print('norm encoding: %r' % norm_encoding)
360 norm_encoding = encodings.aliases.aliases.get(norm_encoding.lower(),
361 norm_encoding)
362 #print('aliased encoding: %r' % norm_encoding)
363 encoding = norm_encoding
364 norm_encoding = norm_encoding.lower()
365 if norm_encoding in locale_encoding_alias:
366 encoding = locale_encoding_alias[norm_encoding]
367 else:
368 norm_encoding = norm_encoding.replace('_', '')
369 norm_encoding = norm_encoding.replace('-', '')
370 if norm_encoding in locale_encoding_alias:
371 encoding = locale_encoding_alias[norm_encoding]
372 #print('found encoding %r' % encoding)
373 return langname + '.' + encoding
374
375def _append_modifier(code, modifier):
376 if modifier == 'euro':

Callers 2

_append_modifierFunction · 0.85
normalizeFunction · 0.85

Calls 4

indexMethod · 0.45
getMethod · 0.45
lowerMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…