2

I have a friend that's been using the jQuery Keypad plugin. He now needs superscripts (and/or perhaps subscripts) of several characters. Does anyone know how to make or find (copy/paste) the following superscript characters in UTF-8?

Superscript characters needed: nd th st rd [ ] ( )

The nd, th, st, rd are for things like 22nd, 7th, 1st, 3rd (but superscripted)

[ ] ( ) would also be needed.

The jQuery Keypad plugin is currently being used with some extra BBCode functionality.

http://keith-wood.name/keypad.html

var custom_keypad_bbcode = [
'⁰|¹|²|³|⁴|⁵|⁶|⁷|⁸|⁹|¢|£|' + $.keypad.QTAT, 
'‘|’|“|”|–|—|©|®|™|¼|½|¾|' + $.keypad.ITALIC, 
'à|á|â|ã|ä|å|æ|ç|è|é|ê|ë|' + $.keypad.QUOTE, 
'ì|í|í|î|ï|ñ|ò|ó|ô|õ|ö|ø|' + $.keypad.ULINE, 
$.keypad.SHIFT + '|ð|þ|ù|ú|û|ü|ý|ÿ|' + $.keypad.CLOSE + '|' + $.keypad.BOLD, 

];

I'm thinking of using BBCode, but I would prefer to write out the characters in a UTF-8. I found the following list, but it doesn't include superscript "t" or "h".

http://www.fileformat.info/info/unicode/block/superscripts_and_subscripts/list.htm

Does anyone know how to make or find (copy/paste) the needed superscript characters in UTF-8?

jjwdesign
  • 3,272
  • 8
  • 41
  • 66
  • Do and not work with jQuery Keypad? – aebabis Feb 14 '14 at 19:54
  • @acbabis - You have to use | separater characters if you want to add it into the keyboard. I have managed to add some BBCode logic using $.keypad.addKeyDef() – jjwdesign Feb 14 '14 at 20:00
  • Ok, so your concern is just making your code cleaner? – aebabis Feb 14 '14 at 20:29
  • No. It's not about the code. Revised Question: Does anyone know how to make or find (copy/paste) the following superscript characters in UTF-8? Superscript characters needed: nd th st rd [ ] ( ) – jjwdesign Feb 14 '14 at 20:53

2 Answers2

1

Superscripts and subscripts for some characters are in the U+2070 – U+209C Unicode range:

  • superscript: 0456789+-=()in

  • subscript: 0123456789+-=aeoxhklmnpst

There's also:

  • subscript j at U+2C7C

  • subscript iruv at U+1D62–U+1D65

  • superscript 123 you have already found

and so-called "phonetic modifier letters" (which for most purposes look like superscript):

  • abdegkmoptuv at U+1D43–U+1D5B

  • c at U+1D9C

  • f at U+1DA0

  • z at U+1DBB

  • hjrwy at U+02B0–U+02B8

  • lsx at U+02E1–U+02E3.

So, assuming you have a font that supports all those characters and the modifier letters look similar to the superscript letters, you have the following:

  • superscript: all digits, all lowercase ASCII letters, and some other symbols

  • subscript: all digits, letters aehijklmnprstuvx, and some other symbols

Karol S
  • 9,028
  • 2
  • 32
  • 45
  • I tried to create the superscript "nd" with unicode characters x207F (n) and x1D48 (d), but the result did not have the same baseline due to the different letter types. Any suggestions? – jjwdesign Feb 17 '14 at 17:10
  • You can try looking for another font. Maybe in fact they do line up, but the two letters you saw wre actually from different fonts, one supporting only ona character and the other one the second one? – Karol S Feb 18 '14 at 00:50
0

Here's what I eventually came up with in PHP. Yet, the baseline for the 'nd' is not at one level.

// Testing: Superscript characters needed: nd th st rd [ ] ( )

// nd ⁿᵈ
echo "nd: ".html_entity_decode('&#x207F;', ENT_COMPAT, 'UTF-8').html_entity_decode('&#x1D48;', ENT_COMPAT, 'UTF-8')."<br>";
// th ᵗʰ (t-x1D57) ᵗʰ (H-x2b0)
echo "th: ".html_entity_decode('&#x1D57;', ENT_COMPAT, 'UTF-8').html_entity_decode('&#x02b0;', ENT_COMPAT, 'UTF-8')."<br>";
// st ˢᵗ
echo "st: ".html_entity_decode('&#X02E2;', ENT_COMPAT, 'UTF-8').html_entity_decode('&#x1D57;', ENT_COMPAT, 'UTF-8')."<br>";
// rd ʳᵈ
echo "rd: ".html_entity_decode('&#X02B3;', ENT_COMPAT, 'UTF-8').html_entity_decode('&#x1D48;', ENT_COMPAT, 'UTF-8')."<br>";

echo "<br><br><br>";

echo "n-".html_entity_decode('&#x207F;', ENT_COMPAT, 'UTF-8');
echo "d-".html_entity_decode('&#x1D48;', ENT_COMPAT, 'UTF-8');
echo "h-".html_entity_decode('&#X02B0;', ENT_COMPAT, 'UTF-8');
echo "r-".html_entity_decode('&#X02B3;', ENT_COMPAT, 'UTF-8');
echo "s-".html_entity_decode('&#X02E2;', ENT_COMPAT, 'UTF-8');
echo "t-".html_entity_decode('&#x1D57;', ENT_COMPAT, 'UTF-8');
jjwdesign
  • 3,272
  • 8
  • 41
  • 66