Replaces the dakuten and handakuten modifier character combinations
        with single characters. For example, か\u3099か becomes がけ,
        or は゜は becomes ぱは.
977878
def _normalize_dakuten(self, chars):
        '''
        
        '''
        prev = None
        prev_n = None

        # Set all repeater characters to 0 initially,
        # then go through the list and remove them all.
        for n in range(len(chars)):
            char = chars[n]

            if char in dkt:
                chars[n] = 0
                if prev in dkt_cvs:
                    chars[prev_n] = dkt_lt[prev]

            if char in hdkt:
                chars[n] = 0
                if prev in hdkt_cvs:
                    chars[prev_n] = hdkt_lt[prev]

            prev = char
            prev_n = n

        # Remove all 0 values. There should not be any other than the ones we
        # just added. (This could use (0).__ne__, but that's Python 3 only.)
        return list(filter(lambda x: x is not 0, chars))
1228093
def _switch_charset_list(characters, target=''):
    '''
    
    '''
    # Copy the list to avoid modifying the existing one.
    characters = characters[:]
    offset = block_offset * offsets[target]['direction']
    for n in range(len(characters)):
        chars = list(characters[n])

        for m in range(len(chars)):
            char = chars[m]
            char_offset = ord(char) + offset
            # Verify that the offset character is within the valid range.
            if in_range(char_offset, target):
                chars[m] = chr(char_offset)
            else:
                chars[m] = char

        characters[n] = ''.join(chars)

    return characters
1180691
def cjkFragSplit(frags, maxWidths, calcBounds, encoding='utf8'):
    

    from reportlab.rl_config import _FUZZ

    U = []  # get a list of single glyphs with their widths etc etc
    for f in frags:
        text = f.text
        if not isinstance(text, unicode):
            text = text.decode(encoding)
        if text:
            U.extend([cjkU(t, f, encoding) for t in text])
        else:
            U.append(cjkU(text, f, encoding))

    lines = []
    widthUsed = lineStartPos = 0
    maxWidth = maxWidths[0]

    for i, u in enumerate(U):
        w = u.width
        widthUsed += w
        lineBreak = hasattr(u.frag, 'lineBreak')
        endLine = (widthUsed > maxWidth + _FUZZ and widthUsed > 0) or lineBreak
        if endLine:
            if lineBreak: continue
            extraSpace = maxWidth - widthUsed + w
            #This is the most important of the Japanese typography rules.
            #if next character cannot start a line, wrap it up to this line so it hangs
            #in the right margin. We won't do two or more though - that's unlikely and
            #would result in growing ugliness.
            nextChar = U[i]
            if nextChar in ALL_CANNOT_START:
                extraSpace -= w
                i += 1
            lines.append(makeCJKParaLine(U[lineStartPos:i], extraSpace, calcBounds))
            try:
                maxWidth = maxWidths[len(lines)]
            except IndexError:
                maxWidth = maxWidths[-1]  # use the last one

            lineStartPos = i
            widthUsed = w
            i -= 1
        #any characters left?
    if widthUsed > 0:
        lines.append(makeCJKParaLine(U[lineStartPos:], maxWidth - widthUsed, calcBounds))

    return ParaLines(kind=1, lines=lines)
70818
def single_encode(input, errors='strict'):
    
    if not isinstance(input, text_type):
        input = text_type(input, sys.getdefaultencoding(), errors)
    length = len(input)
    input = unicodedata.normalize('NFKC', input)
    return input.translate(single_table), length
797229
public static final String collateCharset(String charset) {
        String[] output = StringUtils.split(charset, "COLLATE");
        return output[0].replace('\'', ' ').trim();
    }
876454
private StringBuilder wrapIfComment(final StringBuilder original, final StringBuilder addParts,
			final TableMetadata.Column col) {
		String camelColName = col.getCamelColumnName();
		// フィールドがセットされていない場合はカラム自体を削る
		if (isStringType(col.getDataType())) {
			if (emptyStringEqualsNull) {
				original.append("/*IF SF.isNotEmpty(").append(camelColName).append(") */")
						.append(System.lineSeparator());
			} else {
				original.append("/*IF ").append(camelColName).append(" != null */").append(System.lineSeparator());
			}
		} else {
			original.append("/*IF ").append(camelColName).append(" != null */").append(System.lineSeparator());
		}
		original.append(addParts);
		original.append("/*END*/").append(System.lineSeparator());
		return original;
	}
1058816
function replaceSpecialChars(item) {
	if (!j79.isString(item)) {
		return item;
	}

	var result = item;

	var specialChars = Object.keys(SPECIAL_CHARS_MAP);
	for (var index in specialChars) {
		result = replaceSpecialChar(result, specialChars[index]);
	}

	return result;
}
978750
def h2z(text, ignore='', kana=True, ascii=False, digit=False):
    
    def _conv_dakuten(text):
        """
        半角濁点カナを全角に変換
        """
        text = text.replace(u"ｶﾞ", u"ガ").replace(u"ｷﾞ", u"ギ")
        text = text.replace(u"ｸﾞ", u"グ").replace(u"ｹﾞ", u"ゲ")
        text = text.replace(u"ｺﾞ", u"ゴ").replace(u"ｻﾞ", u"ザ")
        text = text.replace(u"ｼﾞ", u"ジ").replace(u"ｽﾞ", u"ズ")
        text = text.replace(u"ｾﾞ", u"ゼ").replace(u"ｿﾞ", u"ゾ")
        text = text.replace(u"ﾀﾞ", u"ダ").replace(u"ﾁﾞ", u"ヂ")
        text = text.replace(u"ﾂﾞ", u"ヅ").replace(u"ﾃﾞ", u"デ")
        text = text.replace(u"ﾄﾞ", u"ド").replace(u"ﾊﾞ", u"バ")
        text = text.replace(u"ﾋﾞ", u"ビ").replace(u"ﾌﾞ", u"ブ")
        text = text.replace(u"ﾍﾞ", u"ベ").replace(u"ﾎﾞ", u"ボ")
        text = text.replace(u"ﾊﾟ", u"パ").replace(u"ﾋﾟ", u"ピ")
        text = text.replace(u"ﾌﾟ", u"プ").replace(u"ﾍﾟ", u"ペ")
        return text.replace(u"ﾎﾟ", u"ポ").replace(u"ｳﾞ", u"ヴ")

    if ascii:
        if digit:
            if kana:
                h2z_map = H2Z_ALL
            else:
                h2z_map = H2Z_AD
        elif kana:
            h2z_map = H2Z_AK
        else:
            h2z_map = H2Z_A
    elif digit:
        if kana:
            h2z_map = H2Z_DK
        else:
            h2z_map = H2Z_D
    else:
        h2z_map = H2Z_K
    if kana:
        text = _conv_dakuten(text)
    if ignore:
        h2z_map = _exclude_ignorechar(ignore, h2z_map.copy())
    return _convert(text, h2z_map)
208645
public static String parseFromUnicode(
    String input,
    EmojiTransformer transformer
  ) {
    int prev = 0;
    StringBuilder sb = new StringBuilder();
    List<UnicodeCandidate> replacements = getUnicodeCandidates(input);
    for (UnicodeCandidate candidate : replacements) {
      sb.append(input.substring(prev, candidate.getEmojiStartIndex()));

      sb.append(transformer.transform(candidate));
      prev = candidate.getFitzpatrickEndIndex();
    }

    return sb.append(input.substring(prev)).toString();
  }
1357685
@PublicAPI("Used by fb-contrib-eclipse-quickfixes to determine type of fix to apply")
    public static Map<String, Integer> getUnreplaceableCharsetEncodings() {
        Map<String, Integer> encodings = new HashMap<>((int) (UNREPLACEABLE_ENCODING_METHODS.size() * 1.6));
        for (Map.Entry<FQMethod, Integer> entry : UNREPLACEABLE_ENCODING_METHODS.entrySet()) {
            encodings.put(entry.getKey().toString(), entry.getValue());
        }
        return encodings;
    }
266048
@PublicAPI("Used by fb-contrib-eclipse-quickfixes to determine type of fix to apply")
    public static Map<String, Integer> getReplaceableCharsetEncodings() {
        Map<String, Integer> encodings = new HashMap<>((int) (REPLACEABLE_ENCODING_METHODS.size() * 1.6));
        for (Map.Entry<FQMethod, Integer> entry : REPLACEABLE_ENCODING_METHODS.entrySet()) {
            encodings.put(entry.getKey().toString(), entry.getValue());
        }
        return encodings;
    }
81170
private static String replaceLettersWithNumbersKeypad(String str, String locale) {
    if (locale.toLowerCase().startsWith("en")) {
      return str.replaceAll("[AaBbCc]", "2").replaceAll("[DdEeFf]", "3").replaceAll("[GgHhIi]", "4")
          .replaceAll("[JjKkLl]", "5").replaceAll("[MmNnOo]", "6").replaceAll("[PpQqRrSs]", "7")
          .replaceAll("[TtUuVv]", "8").replaceAll("[WwXxYyZz]", "9").replaceAll("-", "");
       }
    return str.replaceAll("-", "");
  }
728587
private String getAlgName(int ch, int choice)
    {
        /* Only the normative character name can be algorithmic. */
        if (choice == UCharacterNameChoice.UNICODE_CHAR_NAME ||
            choice == UCharacterNameChoice.EXTENDED_CHAR_NAME
        ) {
            // index in terms integer index
            synchronized (m_utilStringBuffer_) {
                m_utilStringBuffer_.setLength(0);

                for (int index = m_algorithm_.length - 1; index >= 0; index --)
                {
                   if (m_algorithm_[index].contains(ch)) {
                      m_algorithm_[index].appendName(ch, m_utilStringBuffer_);
                      return m_utilStringBuffer_.toString();
                   }
                }
            }
        }
        return null;
    }
972291
def deramise(r):
    
    return r.replace('J', 'I') \
            .replace('j', 'i') \
            .replace('v', 'u') \
            .replace("æ", "ae") \
            .replace("Æ", "Ae") \
            .replace("œ", "oe") \
            .replace("Œ", "Oe") \
            .replace("ụ", 'u') \
            .replace('V', 'U')
23510
public String convertToJavaString(String input, boolean useUnicode) {
		int length = input.length();
		StringBuilder result = new StringBuilder(length + 4);
		for (int i = 0; i < length; i++) {
			escapeAndAppendTo(input.charAt(i), useUnicode, result);
		}
		return result.toString();
	}
712827
def encode_katakana(text):
    """"""
    encoded = []
    for char in text:
        if jaconv:
            # try to convert japanese text to half-katakanas
            char = jaconv.z2h(jaconv.hira2kata(char))
            # TODO: "the conversion may result in multiple characters"
            # If that really can happen (I am not really shure), than the string would have to be split and every single
            #  character has to passed through the following lines.

        if char in TXT_ENC_KATAKANA_MAP:
            encoded.append(TXT_ENC_KATAKANA_MAP[char])
        else:
            # TODO doesn't this discard all that is not in the map? Can we be sure that the input does contain only
            # encodable characters? We could at least throw an exception if encoding is not possible.
            pass
    return b"".join(encoded)
805608
def replace_unicode(self, m):
        """"""

        groups = m.groupdict()
        esc = m.group(0)
        if groups.get('fesc'):
            value = m.group(0)
        elif groups.get('format'):
            value = ' '
        elif groups.get('special'):
            value = BACK_SLASH_TRANSLATION[esc]
        elif groups.get('char'):
            try:
                value = chr(int(esc[2:], 16))
            except Exception:
                value = esc
        elif groups.get('oct'):
            value = chr(int(esc[1:], 8))
        elif groups.get('name'):
            try:
                value = unicodedata.lookup(esc[3:-1])
            except Exception:
                value = esc
        return value.replace('\x00', '\n')