Replace character with new unicode character

@return unicode character
966414
public function encode()
    {
    	foreach ($this->body as $key => $value) {
    		$result[] = $this->replaceText($value);
    	}

    	return implode('', $result);
    }
352090
public function asCharacterString(): Primitive\CharacterString
    {
        if (!$this->_element instanceof Primitive\CharacterString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_CHARACTER_STRING));
        }
        return $this->_element;
    }
1195429
def replace(html, replacements=None):
    """"""
    if not replacements:
        return html  # no replacements
    html = HTMLFragment(html)

    for r in replacements:
        r.replace(html)

    return unicode(html)
212146
def new_character(self, name, data=None, **kwargs):
        """"""
        self.add_character(name, data, **kwargs)
        return self.character[name]
502525
public static String replace(String string, char oldChar, char newChar) {
        return checkNull(string).replace(oldChar, newChar);
    }
469769
public static String replaceCRToken(final String original) {
        String toReplace = original;

        if (original != null && original.indexOf(NEWLINE_TOKEN) >= 0) {
            toReplace = StringUtil.replace(NEWLINE_TOKEN, NEW_LINE, original);
        }

        return toReplace;
    }
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')
550035
public String replaceString(String string, String strTarget, String strReplace)
    {
        int iIndex = 0;
        while ((iIndex = string.indexOf(strTarget, iIndex)) != -1)
        {
            char chNext = ' ';
            char chPrev = ' ';
            if (string.length() > iIndex + strTarget.length())
                chNext = string.charAt(iIndex + strTarget.length());
            if (iIndex > 1)
                chPrev = string.charAt(iIndex - 1);
            if (COMPARE_ANY_STRING)
            {   // Compare any string, not just names
                chNext = '.';
                chPrev = '.';
            }
            if (Character.isLetterOrDigit(chNext))
            { // Alphanumeric = longer than target.. don't change
                iIndex = iIndex + strTarget.length();
            }
            else if (Character.isLetterOrDigit(chPrev))
            { // Alphanumeric = longer than target.. don't change
                iIndex = iIndex + strTarget.length();
            }
            else
            { // space/other = end of char.. change
                string = string.substring(0, iIndex) + strReplace + string.substring(iIndex + strTarget.length());
                iIndex = iIndex + strReplace.length();
System.out.println("New String " + string);
            }
        }
        return string;
    }
21528
function toUnicode(theString) {
    let unicodeString = ''
    for (var i=0; i < theString.length; i++) {
        let theUnicode = theString.charCodeAt(i).toString(16).toUpperCase()
        while (theUnicode.length < 4) {
            theUnicode = '0' + theUnicode
        }
        theUnicode = '\\u' + theUnicode
        unicodeString += theUnicode
    }
    return unicodeString
}
230912
public AsciiString toLowerCase() {
        boolean lowercased = true;
        int i, j;
        final int len = length() + arrayOffset();
        for (i = arrayOffset(); i < len; ++i) {
            byte b = value[i];
            if (b >= 'A' && b <= 'Z') {
                lowercased = false;
                break;
            }
        }

        // Check if this string does not contain any uppercase characters.
        if (lowercased) {
            return this;
        }

        final byte[] newValue = PlatformDependent.allocateUninitializedArray(length());
        for (i = 0, j = arrayOffset(); i < newValue.length; ++i, ++j) {
            newValue[i] = toLowerCase(value[j]);
        }

        return new AsciiString(newValue, false);
    }
200236
public static Character toCharacter(Object o) throws PageException {
	if (o instanceof Character) return (Character) o;
	return new Character(toCharValue(o));

    }
255827
public static String replace(final CharSequence target, final CharSequence replacement, final String string) {
    return Pattern.compile(quote(target.toString())/*
                                                    * , Pattern.LITERAL jdk 1.4
                                                    */).matcher(string).replaceAll(
    /* Matcher. jdk 1.4 */quoteReplacement(replacement.toString()));
  }
695483
public static Character toChar(Object value, Character defaultValue) {
		return convert(Character.class, value, defaultValue);
	}
235267
public static String escape(String value)
    {
        String search = "&<>";
        String[] replace = {"&amp;", "&lt;", "&gt;"};

        StringBuilder buf = new StringBuilder();

        for (int i = 0; i < value.length(); i++)
        {
            char c = value.charAt(i);
            int pos = search.indexOf(c);
            if (pos < 0)
                buf.append(c);
            else
                buf.append(replace[pos]);
        }

        return buf.toString();
    }
1140530
public static String unicodeEncode(String s) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < s.length(); ++i) {
            char ch = s.charAt(i);
            if (ch >= '\u0080') {
                String st = Integer.toHexString(0x10000 + (int) ch);
                while (st.length() < 4) st = "0" + st;
                buf.append("\\u").append(st.subSequence(1, 5));
            } else {
                buf.append(ch);
            }
        }
        return buf.toString();
    }
35690
private static String replaceChars(String str)
  {
    StringBuffer buf = new StringBuffer(str);
    int length = buf.length();
    for (int i = 0; i < length; i++)
    {
      char currentChar = buf.charAt(i);
      // Replace space with "%20"
      if (currentChar == ' ')
      {
        buf.setCharAt(i, '%');
        buf.insert(i+1, "20");
        length = length + 2;
        i = i + 2;
      }
      // Replace backslash with forward slash
      else if (currentChar == '\\')
      {
        buf.setCharAt(i, '/');
      }
    }

    return buf.toString();
  }
124378
@Expose
    public static String replaceSupplementary(final String value)
    {
        return InterpolationHelper.replaceSupplementary(value, new Replacer()
        {
            public String replace(String in)
            {
                StringBuilder uc = new StringBuilder();

                for (char c : in.toCharArray())
                {
                    uc.append("\\\\u");
                    uc.append(Integer.toHexString(c).toUpperCase());
                }

                return uc.toString();
            }
        });
    }