javascript 如何找到下标字母的unicode?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17908593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 10:04:16  来源:igfitidea点击:

How to find the unicode of the subscript alphabet?

javascriptunicodethree.jssubscript

提问by Mahmoud Elgohary

I've found some letters but i need to find others such as "c", "m", "p", is this even possible?

我找到了一些字母,但我需要找到其他字母,例如“c”、“m”、“p”,这可能吗?

回答by Kevin Hakanson

Take a look at the wikipedia article Unicode subscripts and superscripts. It looks like these are spread out across different ranges, and not all characters are available.

查看维基百科文章Unicode 下标和上标。看起来这些分布在不同的范围内,并非所有字符都可用。

Consolidated for cut-and-pasting purposes, the Unicode standard defines complete sub- and super-scripts for numbers and common mathematical symbols ( ? 1 2 3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ), a full superscript Latin lowercase alphabet except q ( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ), a limited uppercase Latin alphabet ( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ), a few subscripted lowercase letters ( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ), and some Greek letters ( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ). Note that since these glyphs come from different ranges, they may not be of the same size and position, depending on the typeface.

Unicode 标准为剪切和粘贴目的而合并,为数字和常用数学符号定义了完整的下标和上标 (? 1 2 3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ),一个完整的上标拉丁小写字母,除了 q (?? (???????????????字母(? ? ? ? ? ? ? ? ? ? ? ? ? ). 请注意,由于这些字形来自不同的范围,因此它们的大小和位置可能不同,具体取决于字体。

回答by winerd

You can copy the charactersfrom the Wikipedia page mentioned in the other answer. Then in python

您可以characters从另一个答案中提到的维基百科页面复制。然后在python中

characters = '? 1 2 3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'
for c in characters.split():
    print(c + '=' + hex(ord(c)))

?=0x2070 1=0xb9 2=0xb2 3=0xb3 ?=0x2074 ?=0x2075 ?=0x2076 ?=0x2077 ?=0x2078 ?=0x2079 ?=0x207a ?=0x207b ?=0x207c ?=0x207d ?=0x207e

?=0x2070 1=0xb9 2=0xb2 3=0xb3 ?=0x2074 ?=0x2075 ?=0x2076 ?=0x2077 ?=0x2078 ?=0x2079 ?=0x207a ?72b=0x207a ?72b=0x207a ?72b=0x2074 ?=0x2075 ?=0x2076

?=0x2080 ?=0x2081 ?=0x2082 ?=0x2083 ?=0x2084 ?=0x2085 ?=0x2086 ?=0x2087 ?=0x2088 ?=0x2089 ?=0x208a ?=0x208b ?=0x208c ?=0x208d ?=0x208e

?=0x2080 ?=0x2081 ?=0x2082 ?=0x2083 ?=0x2084 ?=0x2085 ?=0x2086 ?=0x2087 ?=0x2088 ?=0x2089 ?=0x2089 ?=0x20b=0x20b=0x200d=0x200

?=0x1d43 ?=0x1d47 ?=0x1d9c ?=0x1d48 ?=0x1d49 ?=0x1da0 ?=0x1d4d ?=0x2b0 ?=0x2071 ?=0x2b2 ?=0x1d4f ?=0x2e1 ?=0x1d50 ?=0x207f ?=0x1d52 ?=0x1d56 ?=0x2b3 ?=0x2e2 ?=0x1d57 ?=0x1d58 ?=0x1d5b ?=0x2b7 ?=0x2e3 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?=0x1d68 ?=0x1d69 ?=0x1d6a

?=0x1d66 ?=0x1d67 ?=0x1d68 ?=0x1d69 ?=0x1d6a

回答by Bill Moore

import sys
# on windows run from QtConsole for unicode
#  (Cmd console only support codepage characters)
#  At present (6/10/2017), superscripts/subscript chars
#  are best viewed with terminal/text-editor set to monospace font
#       "DejaVu Sans Mono"
#  "Consolas" works also, but is missing a few characters...
#  and, "Courier" has the worst support at present...

if int(sys.version[0]) != 3:
    print('Aborted: Python 3.x required')
    sys.exit(1)

def table():
    unicode_map = {
         #           superscript     subscript
        '0'        : ('\u2070',   '\u2080'      ),
        '1'        : ('\u00B9',   '\u2081'      ),
        '2'        : ('\u00B2',   '\u2082'      ),
        '3'        : ('\u00B3',   '\u2083'      ),
        '4'        : ('\u2074',   '\u2084'      ),
        '5'        : ('\u2075',   '\u2085'      ),
        '6'        : ('\u2076',   '\u2086'      ),
        '7'        : ('\u2077',   '\u2087'      ),
        '8'        : ('\u2078',   '\u2088'      ),
        '9'        : ('\u2079',   '\u2089'      ),
        'a'        : ('\u1d43',   '\u2090'      ),
        'b'        : ('\u1d47',   '?'           ),
        'c'        : ('\u1d9c',   '?'           ),
        'd'        : ('\u1d48',   '?'           ),
        'e'        : ('\u1d49',   '\u2091'      ),
        'f'        : ('\u1da0',   '?'           ),
        'g'        : ('\u1d4d',   '?'           ),
        'h'        : ('\u02b0',   '\u2095'      ),
        'i'        : ('\u2071',   '\u1d62'      ),
        'j'        : ('\u02b2',   '\u2c7c'      ),
        'k'        : ('\u1d4f',   '\u2096'      ),
        'l'        : ('\u02e1',   '\u2097'      ),
        'm'        : ('\u1d50',   '\u2098'      ),
        'n'        : ('\u207f',   '\u2099'      ),
        'o'        : ('\u1d52',   '\u2092'      ),
        'p'        : ('\u1d56',   '\u209a'      ),
        'q'        : ('?',        '?'           ),
        'r'        : ('\u02b3',   '\u1d63'      ),
        's'        : ('\u02e2',   '\u209b'      ),
        't'        : ('\u1d57',   '\u209c'      ),
        'u'        : ('\u1d58',   '\u1d64'      ),
        'v'        : ('\u1d5b',   '\u1d65'      ),
        'w'        : ('\u02b7',   '?'           ),
        'x'        : ('\u02e3',   '\u2093'      ),
        'y'        : ('\u02b8',   '?'           ),
        'z'        : ('?',        '?'           ),
        'A'        : ('\u1d2c',   '?'           ),
        'B'        : ('\u1d2e',   '?'           ),
        'C'        : ('?',        '?'           ),
        'D'        : ('\u1d30',   '?'           ),
        'E'        : ('\u1d31',   '?'           ),
        'F'        : ('?',        '?'           ),
        'G'        : ('\u1d33',   '?'           ),
        'H'        : ('\u1d34',   '?'           ),
        'I'        : ('\u1d35',   '?'           ),
        'J'        : ('\u1d36',   '?'           ),
        'K'        : ('\u1d37',   '?'           ),
        'L'        : ('\u1d38',   '?'           ),
        'M'        : ('\u1d39',   '?'           ),
        'N'        : ('\u1d3a',   '?'           ),
        'O'        : ('\u1d3c',   '?'           ),
        'P'        : ('\u1d3e',   '?'           ),
        'Q'        : ('?',        '?'           ),
        'R'        : ('\u1d3f',   '?'           ),
        'S'        : ('?',        '?'           ),
        'T'        : ('\u1d40',   '?'           ),
        'U'        : ('\u1d41',   '?'           ),
        'V'        : ('\u2c7d',   '?'           ),
        'W'        : ('\u1d42',   '?'           ),
        'X'        : ('?',        '?'           ),
        'Y'        : ('?',        '?'           ),
        'Z'        : ('?',        '?'           ),         
        '+'        : ('\u207A',   '\u208A'      ),
        '-'        : ('\u207B',   '\u208B'      ),
        '='        : ('\u207C',   '\u208C'      ),
        '('        : ('\u207D',   '\u208D'      ),
        ')'        : ('\u207E',   '\u208E'      ),        
        ':alpha'   : ('\u1d45',   '?'           ), 
        ':beta'    : ('\u1d5d',   '\u1d66'      ), 
        ':gamma'   : ('\u1d5e',   '\u1d67'      ), 
        ':delta'   : ('\u1d5f',   '?'           ), 
        ':epsilon' : ('\u1d4b',   '?'           ), 
        ':theta'   : ('\u1dbf',   '?'           ),
        ':iota'    : ('\u1da5',   '?'           ),
        ':pho'     : ('?',        '\u1d68'      ),
        ':phi'     : ('\u1db2',   '?'           ),
        ':psi'     : ('\u1d60',   '\u1d69'      ),
        ':chi'     : ('\u1d61',   '\u1d6a'      ),
        ':coffee'  : ('\u2615',   '\u2615'      )
    }

    keys = sorted(unicode_map.keys())

    for key in keys:
        spr = "X" + unicode_map[key][0] 
        sub = "X" + unicode_map[key][1]        
        if (spr == "X?"): spr = ""
        if (sub == "X?"): sub = ""
        print('%-15s %s %s' % (key, spr, sub))

table()