1. Decode the string to Unicode. Assuming it's UTF-8-encoded:

    str.decode("utf-8")
    
  2. Call the replace method and be sure to pass it a Unicode string as its first argument:

    str.decode("utf-8").replace(u"\u2022", "*")
    
  3. Encode back to UTF-8, if needed:

    str.decode("utf-8").replace(u"\u2022", "*").encode("utf-8")
    

(Fortunately, Python 3 puts a stop to this mess. Step 3 should really only be performed just prior to I/O. Also, mind you that calling a string str shadows the built-in type str.)

Answer from Fred Foo on Stack Overflow
🌐
Wikipedia
en.wikipedia.org › wiki › Specials_(Unicode_block)
Specials (Unicode block) - Wikipedia
June 6, 2026 - Its block name in Unicode 1.0 was Special. The replacement character � (often displayed as a rhombus with a question mark) is a symbol found in the Unicode standard at code point U+FFFD in the Specials table.
Discussions

Replacing special characters in highlighted text
Any of those should work. However, you have to input the characters as unicode characters, and not as hex unicode code points. For a single character where you know the hex code point (00a0), the easiest is via C-x 8 RET— just type that and enter the hex code point: 00a0 followed by RET. Alternatively, you can just use cut-and-paste. More on reddit.com
🌐 r/emacs
4
5
December 20, 2021
python - replace special characters using unicode - Stack Overflow
how can i replace the double quotation marks with the stylistically correct quotation marks („ U+201e or “ U+201c ) according to German spelling. example: zitat = 'Laut Durkheim ist ein " More on stackoverflow.com
🌐 stackoverflow.com
January 9, 2021
ascii - Search and replace unicode character codes with actual characters - Vi and Vim Stack Exchange
I've got a text file with unicode character codes in it. It looks like this in vim (utf-8[unix]): Samuel i ngel - Euro 25 Tomas i lvaro - ©Coca-Cola and dagger More on vi.stackexchange.com
🌐 vi.stackexchange.com
March 8, 2023
php - Replace unicode formatted special characters - Stack Overflow
Unfortunately my string looks like ... are file names and OSX seems to convert the characters to unicode (at least that is what i think). I know that i could use a very long array with all special characters to replace them in PHP:... More on stackoverflow.com
🌐 stackoverflow.com
May 24, 2017
🌐
Reddit
reddit.com › r/emacs › replacing special characters in highlighted text
r/emacs on Reddit: Replacing special characters in highlighted text
December 20, 2021 -

I have a selected text and am trying to replace all `\u00a0` special characters in it with an empty space. Is this possible to do with a simple command without resorting to writing my own implementation (something like `:%s/\%u00a0/ /g` in vim). So far i have tried `replace-string`, `replace-regexp` and `query-replace`. Any attempt says that there were 0 occurrences.

🌐
Community
community.safe.com › home › forums › fme form › transformers › convert a text character to another unicode character and use as a label?
Convert a text character to another Unicode character and use as a label? | Community
October 27, 2021 - If the text string is "AxyAx" (x, y being any other characters), every "A" should be substituted with one instance of the new unicode character (the roman numeral "I" in my example).
Find elsewhere
Top answer
1 of 6
4

I use a javascript bookmarklet for typing unicode symbols at math.stackexchange.com. Mathjax renders most unicode the same as the corresponding latex macros. For example $ℝ$ and $\mathbb{R}$ give the same result. I like the way tex code stays more compact and readable with unicode symbols.

I think this code is able to do what you want. I like to use not too many keystrokes, so instead of \alpha I use \a to produce α. You can modify this script to your own needs, and then convert it to a bookmarklet, using this website for example: http://jasonmillerdesign.com/Free_Stuff/Instant_Bookmarklet_Converter

If you want to use this script on a website without jquery, then you first need to run this bookmarklet: http://www.learningjquery.com/2006/12/jquerify-bookmarklet/

jQuery.fn.autocorrect = function(options)
{
    if ("text" != jQuery(this).attr("type") && !jQuery(this).is("textarea"))
    {
        return;
    }
var defaults = {
        corrections: {
            a: "α",
            b: "β",
            c: "γ",
            d: "δ",
            e: "ϵ",
            emp : "∅",
            f: "\\frac{}{}",
            in : "∈",
            s: "σ",
            t: "\\text{}",
            tau : "τ",
            th : "θ",
            p: "π",
            pm : "±",
            o : "ω",
            O : "Ω",
            r : "ρ",
            A : "∀",
            E : "∃",
            R: "ℝ",
            C: "ℂ",
            H: "ℍ",
            N: "ℕ",
            Q: "ℚ",
            Z: "ℤ",
            int: "\\int_{}^{}",
            inf : "∞",
            sum : "\\sum_{}^{}",
            "-1": "^{-1}",
            ph: "ϕ",
            ch: "χ",
            ps: "ψ",
            leq : "≥",
            xi : "ξ", 
            geq : "≤",
            "/=" : "≠",
            "==" : "≡",
            "<" : "\\langle {} \\rangle",
            "->" : "→",
            "=>" : "⇒",
            "<=" : "⇐",
            "<>" : "⇔",
            "sq" : "\\sqrt{}"
    }
};
if (options && options.corrections)
{
    options.corrections = jQuery.extend(defaults.corrections, options.corrections);
}
var opts = jQuery.extend(defaults, options);
getCaretPosition = function(oField)
{
    var iCaretPos = 0;
    if (document.selection)
    {
        var oSel = document.selection.createRange();
        oSel.moveStart("character", 0 - oField.value.length);
        iCaretPos = oSel.text.length;
    }
    else if (oField.selectionStart || oField.selectionStart == "0")
    {
        iCaretPos = oField.selectionStart;
    }
    return (iCaretPos);
}
function setCaretPosition (oField, iCaretPos)
{
    if (document.selection)
    {
        var oSel = document.selection.createRange();
        oSel.moveStart("character", 0 - oField.value.length);
        oSel.moveStart("character", iCaretPos);
        oSel.moveEnd("character", 0);
    }
    else if (oField.selectionStart || oField.selectionStart == "0")
    {
        oField.selectionStart = iCaretPos;
        oField.selectionEnd = iCaretPos;
    }
}
this.keyup(function(e)
{
    if (32 != e.keyCode)
    {
        return;
    }
    var caretPosition = (getCaretPosition(this) - 1);
    if (1 > caretPosition)
    {
        return;
    }
    var valueOfField = this.value;
    var stringUptoCaretPosition = (valueOfField).substr(0, caretPosition);
    if (" " == stringUptoCaretPosition.charAt(caretPosition - 1))
    {
        return;
    }
    var beginIndex = stringUptoCaretPosition.lastIndexOf('\\');
    if (beginIndex < stringUptoCaretPosition.lastIndexOf(' '))
    {
        return;
    }
    var stringToSearch = stringUptoCaretPosition.substring(beginIndex+1);
    var stringNotToSearch = stringUptoCaretPosition.substring(0, beginIndex);
    if (!opts.corrections[stringToSearch])
    {
        return;
    }
    var stringToReplace = opts.corrections[stringToSearch];
    stringUptoCaretPosition = stringNotToSearch+ stringToReplace;
    var stringFromCaretPositionUptoEnd = (valueOfField).substr(caretPosition+1);
    this.value = (stringUptoCaretPosition + stringFromCaretPositionUptoEnd);
    if (stringToReplace.indexOf("{}")!=-1 )
    {
    setCaretPosition(this, stringUptoCaretPosition.indexOf("{}")+1);
    }
    else { setCaretPosition(this, stringUptoCaretPosition.length);}

});
};
$(document).ready(function()
{
    $("textarea").autocorrect();
});
2 of 6
1

Autohotkey-script for converting LaTeX-like input to unicode characters

"Ctrl+Alt+Shift+U" toggles it on and off (look at the bottom right icon to see it's in suspense mode (icon S) of active mode (icon H).

Test: αβΓ∞¹₂ℝ

🌐
DCode
dcode.fr › data processing › text processing › special characters
Special Characters Remover/Detector - Online ASCII Remplacement
Sometimes the encoding is preserved, but special characters are escaped characters (often \). To remove special characters, the user can enter their text in dCode and automatically remove non-ASCII characters or replace them with others.
🌐
Excel Forum
excelforum.com › excel-programming-vba-macros › 960021-find-and-replace-special-characters-unicode.html
Find and replace special characters (unicode) [SOLVED]
October 9, 2013 - When I use the find and replace function this works perfectly, but when I record it into a macro it doesn't recognise it and replaces the instance in the code with a question mark: Please Login or Register to view this content. I'm sure this is quite simple but I can't see a similar post in the forum to refer to. many thanks for all your help! ... I copied the star in the post to cell A1 then in B1: =CODE(A1) which resulted in 63. You should double check. Cells.Replace What:=Chr(63), etc
🌐
Reddit
reddit.com › r/powershell › best way to replace special characters in ad username
r/PowerShell on Reddit: best way to replace special characters in AD username
January 19, 2022 -

Hi Reddit,

I am trying to create a script that creates ad users automatically, however, in my country we have special characters in our name like åäö and such, and i want them replaced with their equivalent a, and o. How am i to proceed with this so the script does it automatically? it is only required for the logins, not the display name and such. My script is set up like this:

$firstname (asks for input)

$surname (asks for input)

$username = $firstname+'.'+$surname ($username is the firstname.lastname@domain.com)

Top answer
1 of 4
4

Word plays internal tricks with Unicode symbols, and doesn't report the true character values. To make successful replacements, use the macros in the article https://wordmvp.com/FAQs/MacrosVBA/FindReplaceSymbols.htm.

2 of 4
0

Hi Jay,

Thank you very much - the macros in the article worked just great!

This was the first time I ever dabbled with VBA in Word, and this worked almost first time. (I do have quite a lot of experience writing VBA macros in Excel, but never in Word.)

Something I learned from using these macros for my specific case - to find and replace all the ?-in-a-rectangles with a regular double quote - is that, in Word t,here is a difference between an opening double quote mark and a closing double quote mark.

At first I highlighted a double quote mark in my document (by chance, a closing one), and used the code that the first macro returned to replace ALL of the ?-in-a-rectangles. This caused the Word spelling & grammar checker to complain that, for all the replaced opening quotes, the adjacent space should go after the quote character. This made me realize that the opening & closing quotes had different codes, though in my document they looked the same. Only when I enlarged the font, was a difference between them discernable.

Also, only the opening ?-in-a-rectangle was replaced by the closing ".  This made me very suspicious, so I used the first macro to display the code of the closing ?-in-a-rectangle - it also was different from the opening character code, which is what I'd used in the second macro.

So I undid all the replacements, and ran the second macro again, twice, each time with the corresponding codes for the opening & closing characters. (8220 --> 147, 8221 --> 148, all (normal text) font)

This time the result was perfect.

many thanks!.

🌐
Community
community.safe.com › home › forums › fme form › transformers › replace unicode character in kml
Replace Unicode character in KML - FME Community
August 1, 2017 - I will go back to the users and tell them, "no special characters in your input, please!" I think this is referred to as a PEBKAC problem (Problem Exists Between Keyboard And Chair). Thanks for everyone's help. ... Try the following regex in a StringReplacer, it will replace any character in a certain unicode range (in the below example it's the range 0800-FFFF) with the replacement text of your choice:
🌐
GitHub
gist.github.com › ruudud › 7193993
Replace special unicode characters (e.g. ❤) with code points in ASCII (e.g. \2764). Written with CSS in mind.
Replace special unicode characters (e.g. ❤) with code points in ASCII (e.g. \2764). Written with CSS in mind. - unicode-to-unihex.sh
🌐
PHP
php.net › manual › en › function.htmlspecialchars.php
PHP: htmlspecialchars - Manual
Check your UI or manual for how to convert files to Unicode. It's also a good idea to figure out where to look in your UI to see what the current file encoding is. ... I had problems with spanish special characters. So i think in using htmlspecialchars but my strings also contain HTML. So I used this :) Hope it help <?php function htmlspanishchars($str) { return str_replace(array("&lt;", "&gt;"), array("<", ">"), htmlspecialchars($str, ENT_NOQUOTES, "UTF-8")); } ?>