sqlpostgresqlpostgresql-9.1superscript

Special superscript characters


How to insert string with super script characters in PostgreSQL?

I want to insert "TM" as power of string "RACH"? I tried the following query:

update contact SET name=E'RACH$^'TM where id='10782'

Solution

  • Use the dedicated characters '®' or '™' as trademark signs.

    UPDATE contact SET name = 'RACH™'  -- '™' not 'ᵀᴹ'
    WHERE  id = '10782';
    

    Some other characters (but not all!) have superscript variants in Unicode, but many fonts don't support these exotic code points and don't even include glyphs to represent them. Except for the common '¹ ² ³', I would rather use formatting to achieve a superscript effect.

    Here on SO, you could use: demo superscript ABC
    That's the output of <sup>demo superscript ABC</sup>
    More info on the Wikipedia page on superscript characters.

    If you need a mapping function use translate(). replace() in a loop would be very inefficient.

    translate('TM', 'ABDEGHIJKLMNOPRTU', 'ᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁ');