Normalize code key value (encoding codecs must be lower case and must
    not contain any dashes).

    :param value: value to convert.
166858
def convert_to_codec_key(value):
    
    if not value:
        # fallback to utf-8
        value = 'UTF-8'
    # UTF-8 -> utf_8
    converted = value.replace('-', '_').lower()
    # fix some corner cases, see https://github.com/pyQode/pyQode/issues/11
    all_aliases = {
        'ascii': [
            'us_ascii',
            'us',
            'ansi_x3.4_1968',
            'cp367',
            'csascii',
            'ibm367',
            'iso_ir_6',
            'iso646_us',
            'iso_646.irv:1991'
        ],
        'utf-7': [
            'csunicode11utf7',
            'unicode_1_1_utf_7',
            'unicode_2_0_utf_7',
            'x_unicode_1_1_utf_7',
            'x_unicode_2_0_utf_7',
        ],
        'utf_8': [
            'unicode_1_1_utf_8',
            'unicode_2_0_utf_8',
            'x_unicode_1_1_utf_8',
            'x_unicode_2_0_utf_8',
        ],
        'utf_16': [
            'utf_16le',
            'ucs_2',
            'unicode',
            'iso_10646_ucs2'
        ],
        'latin_1': ['iso_8859_1']
    }

    for key, aliases in all_aliases.items():
        if converted in aliases:
            return key
    return converted
1105108
def normalizeLibValue(value):
    
    if value is None:
        raise ValueError("Lib value must not be None.")
    if isinstance(value, (list, tuple)):
        for v in value:
            normalizeLibValue(v)
    elif isinstance(value, dict):
        for k, v in value.items():
            normalizeLibKey(k)
            normalizeLibValue(v)
    elif isinstance(value, basestring):
        value = unicode(value)
    return value
576533
def _normalize_utf8_keys(kwargs):
  """"""
  if any(type(key) is binary_type for key in kwargs.keys()):
    # This is to preserve the original dict type for kwargs.
    dict_type = type(kwargs)
    return dict_type([(text_type(k), v) for k, v in kwargs.items()])
  return kwargs
558657
def unescape(value):
    
    pattern = ESCAPE_FMT.replace('%02X', '(?P<code>[0-9A-Fa-f]{2})')
    # the pattern must be bytes to operate on bytes
    pattern_bytes = pattern.encode('ascii')
    re_esc = re.compile(pattern_bytes)
    return re_esc.sub(_unescape_code, value.encode('ascii')).decode('utf-8')
56266
def _normalize(val):
    '''
    
    '''
    if isinstance(val, bool):
        return 'on' if val else 'off'
    return six.text_type(val).lower()
653561
def normalizeFilePath(value):
    
    if not isinstance(value, basestring):
        raise TypeError("File paths must be strings, not %s."
                        % type(value).__name__)
    return unicode(value)
870753
def value_to_python(self, value):
        
        if not isinstance(value, bytes):
            raise tldap.exceptions.ValidationError("should be a bytes")
        value = value.decode("utf_8")
        return value
701809
def normalize_hex(hex_value):
    
    match = HEX_COLOR_RE.match(hex_value)
    if match is None:
        raise ValueError(
            u"'{}' is not a valid hexadecimal color value.".format(hex_value)
        )
    hex_digits = match.group(1)
    if len(hex_digits) == 3:
        hex_digits = u''.join(2 * s for s in hex_digits)
    return u'#{}'.format(hex_digits.lower())
1298495
def normalize_value(text):
    
    result = text.replace('\n', ' ')
    result = re.subn('[ ]{2,}', ' ', result)[0]
    return result
52192
def normalize_value(value):
	""""""

	value = str(value)
	value = value.casefold()

	value = re.sub(r'\/\s*\d+', '', value)  # Remove "/<totaltracks>" from track number.
	value = re.sub(r'^0+([0-9]+)', r'\1', value)  # Remove leading zero(s) from track number.
	value = re.sub(r'^(\d+)\.+', r'\1', value)  # Remove dots from track number.
	value = re.sub(r'[^\w\s]', '', value)  # Remove leading non-word characters.
	value = re.sub(r'^the\s+', '', value)  # Remove leading "the".
	value = re.sub(r'^\s+', '', value)  # Remove leading spaces.
	value = re.sub(r'\s+$', '', value)  # Remove trailing spaces.
	value = re.sub(r'\s+', ' ', value)  # Reduce multiple spaces to a single space.

	return value
32232
def normalizeUnicode(text, encoding='humanascii'):
    
    if text == "":
	return ""

    unicodeinput = True
    if not isinstance(text, unicode):
        text = unicode(text, 'utf-8')
        unicodeinput = False

    res = ''
    global allowed, allowedid
    if encoding == 'humanascii' or encoding == 'identifier':
        enc = 'ascii'
    else:
        enc = encoding
    for ch in text:
        if (encoding == 'humanascii') and (ch in allowed):
            # ASCII chars, digits etc. stay untouched
            res += ch
            continue
        if (encoding == 'identifier') and (ch in allowedid):
            # ASCII chars, digits etc. stay untouched
            res += ch
            continue
        else:
            try:
                ch.encode(enc,'strict')
                if encoding == 'identifier':
                    res += '_'
                else:
                    res += ch
            except UnicodeEncodeError:
                ordinal = ord(ch)
                if mapping.has_key(ordinal):
                    # try to apply custom mappings
                    res += mapping.get(ordinal)
                elif decomposition(ch) or len(normalize('NFKD',ch)) > 1:
                    normalized = filter(lambda i: not combining(i), normalize('NFKD', ch)).strip()
                    # normalized string may contain non-letter chars too. Remove them
                    # normalized string may result to  more than one char
                    if encoding == 'identifier':
                        res += ''.join([c for c in normalized if c in allowedid])
                    else:
                        res += ''.join([c for c in normalized if c in allowed])
                else:
                    # hex string instead of unknown char
                    res += "%x" % ordinal
    if encoding == 'identifier':
        res = res.strip('_').replace('_____','_').replace('____','_').replace('___','_').replace('__','_')
        if not res.strip('_')[0] in string.ascii_letters:
            res = '_' + res
    if unicodeinput:
        return res
    else:
        return res.encode('utf-8')
453571
def _normalize_field_name(value):
    
    # Replace non word/letter character
    return_value = re.sub(r'[^\w\s-]+', '', value)
    # Replaces whitespace with underscores
    return_value = re.sub(r'\s+', '_', return_value)
    return return_value.lower()
855498
def normalizeGlyphUnicode(value):
    
    if not isinstance(value, (int, basestring)) or isinstance(value, bool):
        raise TypeError("Glyph unicode must be a int or hex string, not %s."
                        % type(value).__name__)
    if isinstance(value, basestring):
        try:
            value = int(value, 16)
        except ValueError:
            raise ValueError("Glyph unicode hex must be a valid hex string.")
    if value < 0 or value > 1114111:
        raise ValueError("Glyph unicode must be in the Unicode range.")
    return value
1248053
def normalize_value(value)
      unless value.is_a?(Hash)
        value = value.respond_to?(:to_ary) ? value.to_ary : value.to_str
      end

      # Handle unicode normalization
      if value.kind_of?(Array)
        value.map! { |val| Addressable::IDNA.unicode_normalize_kc(val) }
      elsif value.kind_of?(Hash)
        value = value.inject({}) { |acc, (k, v)|
          acc[Addressable::IDNA.unicode_normalize_kc(k)] =
            Addressable::IDNA.unicode_normalize_kc(v)
          acc
        }
      else
        value = Addressable::IDNA.unicode_normalize_kc(value)
      end
      value
    end
1017537
function normalizeFontSize(value) {
	// "Strip leading and trailing whitespace from value."
	//
	// Cheap hack, not following the actual algorithm.
	value = value.trim();

	// "If value is not a valid floating point number, and would not be a valid
	// floating point number if a single leading "+" character were stripped,
	// abort these steps and do nothing."
	if (!/^[-+]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?$/.test(value)) {
		return null;
	}

	var mode;

	// "If the first character of value is "+", delete the character and let
	// mode be "relative-plus"."
	if (value[0] == "+") {
		value = value.slice(1);
		mode = "relative-plus";
	// "Otherwise, if the first character of value is "-", delete the character
	// and let mode be "relative-minus"."
	} else if (value[0] == "-") {
		value = value.slice(1);
		mode = "relative-minus";
	// "Otherwise, let mode be "absolute"."
	} else {
		mode = "absolute";
	}

	// "Apply the rules for parsing non-negative integers to value, and let
	// number be the result."
	//
	// Another cheap hack.
	var num = parseInt(value);

	// "If mode is "relative-plus", add three to number."
	if (mode == "relative-plus") {
		num += 3;
	}

	// "If mode is "relative-minus", negate number, then add three to it."
	if (mode == "relative-minus") {
		num = 3 - num;
	}

	// "If number is less than one, let number equal 1."
	if (num < 1) {
		num = 1;
	}

	// "If number is greater than seven, let number equal 7."
	if (num > 7) {
		num = 7;
	}

	// "Set value to the string here corresponding to number:" [table omitted]
	value = {
		1: "xx-small",
		2: "small",
		3: "medium",
		4: "large",
		5: "x-large",
		6: "xx-large",
		7: "xxx-large"
	}[num];

	return value;
}
553071
function normalize(value, safe) {
    return value == null
      ? ''
      : value === false
        ? ''
        : Array.isArray(value)
          ? value.map(normalize).join('')
          : safe === false ? $.escapeHTML(value) : String(value)
  }
225642
def normalize(input, case_mapping=protocol.DEFAULT_CASE_MAPPING):
    
    if case_mapping not in protocol.CASE_MAPPINGS:
        raise pydle.protocol.ProtocolViolation('Unknown case mapping ({})'.format(case_mapping))

    input = input.lower()

    if case_mapping in ('rfc1459', 'rfc1459-strict'):
        input = input.replace('{', '[').replace('}', ']').replace('|', '\\')
    if case_mapping == 'rfc1459':
        input = input.replace('~', '^')

    return input