c#中字符串显示上标和下标解决办法

时间:2016-05-21 23:08:31   收藏:0   阅读:3010

  由于工作的需求,需要在word中插入带入带有上标和下标的字符串,比如这样的一个字符串:SO?²?(mg/L)。在网上搜了好久,终是摸索出点思路。

 

  解决办法:使用转义字符加Unicode的HexEntity就可以实现了。比如定义一个SO?²?(mg/L)这样的字符串如下:"SO\x2084\x00B2\x207B(mg/L)"。其中x2084为 ?(注意:此处为4的下标) 的Unicode HexEntity,x00B2为 ²(注意:此处为2的上标) 的Unicode HexEntity,x207B为 ?(注意:此处为-的上标) 的Unicode HexEntity。

  

  一些常用字符如下:

 

Common Arithmetic & Alebgra

Character Name

CharacterEntityNum 
Entity
Hex 
Entity
LESS THAN < &lt; &#60;
GREATER THAN > &gt; &#62;
LESS THAN OR EQUAL TO &le; &#8804;
GREATER THAN OR EQUAL TO &ge; &#8805;
PLUS OR MINUS ± &plusmn; &#177;
NOT EQUALS &ne; &#8800;
DIVISION SIGN ÷ &divide; &#247;
TIMES X × &times; &#215;
MINUS &minus; &#8722;
DIVISION SLASH -- &#8725;
FRACTION SLASH &frasl &#8260;
SQUARE ROOT RADICAL &radic; &#8730;
CUBE ROOT ? -- &#8731;
FOURTH ROOT ? -- &#8732;
INFINITY &infin; &#8734;
ALEF INFINITY SYMBOL &alefsym; &#8501;
FUNCTION ITALIC F ƒ &fnof; &#402;
PRIME (single quote) &prime; &#8242;
DOUBLE PRIME (double quote) &Prime; &#8243;
TRIPLE PRIME (triple quote) ? -- &#8244;
THEREFORE (Triangular Dots) &there4; &#8756;
DOT OPERATOR &sdot; &#8901;
SUPERSCRIPT TWO ¹ &sup1; &#185;
SUPERSCRIPT TWO ² &sup2; &#178;
SUPERSCRIPT THREE ³ &sup3; &#179;
LEFT ANGLE BRACKET &lang; &#9001;
RIGHT ANGLE BRACKET &rang; &#9002;
LEFT CEILING BRACKET &lceil; &#8968;
RIGHT CEILING BRACKET &rceil; &#8969;
LEFT FLOOR BRACKET &lceil; &#8970;
RIGHT FLOOR BRACKET &rceil; &#8971;
CIRCLED PLUS (Direct Sum) &oplus; &#8853;
CIRCLED TIMES (Vector Product) &otimes; &#8855;

 

Superscript Chart(上标)

 

Character NameCharacterNum 
Entity
Hex 
Entity
SUPERSCRIPT ZERO ? &#8304;
SUPERSCRIPT ONE 
Entity Code = &sup1;
¹ &#185;
SUPERSCRIPT TWO 
Entity Code = &sup2;
² &#178;
SUPERSCRIPT THREE 
Entity Code = &sup3;
³ &#179;
SUPERSCRIPT FOUR ? &#8308;
SUPERSCRIPT FIVE ? &#8309;
SUPERSCRIPT SIX ? &#8310;
SUPERSCRIPT SEVEN ? &#8311;
SUPERSCRIPT EIGHT ? &#8312;
SUPERSCRIPT NINE ? &#8313;
SUPERSCRIPT PLUS SIGN ? &#8314;
SUPERSCRIPT MINUS ? &#8315;
SUPERSCRIPT EQUALS SIGN ? &#8316;
SUPERSCRIPT LEFT PARENTHESIS ? &#8317;
SUPERSCRIPT RIGHT PARENTHESIS ? &#8318;
SUPERSCRIPT LATIN SMALL LETTER I ? &#8305;
SUPERSCRIPT LATIN SMALL LETTER N ? &#8319;

 

Subscript Codes(下标)

 

Character NameCharacterNum 
Entity
Hex 
Entity
SUBSCRIPT ZERO ? &#8320;
SUBSCRIPT ONE ? &#8321;
SUBSCRIPT TWO ? &#8322;
SUBSCRIPT THREE ? &#8323;
SUBSCRIPT FOUR ? &#8324;
SUBSCRIPT FIVE ? &#8325;
SUBSCRIPT SIX ? &#8326;
SUBSCRIPT SEVEN ? &#8327;
SUBSCRIPT EIGHT ? &#8328;
SUBSCRIPT NINE ? &#8329;
SUBSCRIPT PLUS SIGN ? &#8330;
SUBSCRIPT MINUS ? &#8331;
SUBSCRIPT EQUALS SIGN ? &#8332;
SUBSCRIPT LEFT PARENTHESIS ? &#8333;
SUBSCRIPT RIGHT PARENTHESIS ? &#8334;
LATIN SUBSCRIPT SMALL LETTER A ? &#8336;
LATIN SUBSCRIPT SMALL LETTER E ? &#8337;
LATIN SUBSCRIPT SMALL LETTER O ? &#8338;
LATIN SUBSCRIPT SMALL LETTER I ? &#7522;
LATIN SUBSCRIPT SMALL LETTER R ? &#7523;
LATIN SUBSCRIPT SMALL LETTER U ? &#7524;
LATIN SUBSCRIPT SMALL LETTER V ? &#7525;
LATIN SUBSCRIPT SMALL LETTER X ? &#8339;
GREEK SUBSCRIPT SMALL LETTER BETA ? &#7526;
GREEK SUBSCRIPT SMALL LETTER GAMMA ? &#7527;
GREEK SUBSCRIPT SMALL LETTER RHO ? &#7528;
GREEK SUBSCRIPT SMALL LETTER PHI ? &#7529;
GREEK SUBSCRIPT SMALL LETTER CHI ? &#7530;

 

Superscript and Subscript

Check these references for other methods to implement superscript/subscript and extra fractions

 

 

Fractions

These codes display fractions set to be all within one line with smaller number, but they can be replaced by other ways of typing a fraction (e.g. "1/2"). 
-- means no HTML entity code exists and that a numeric code must be used.

 

Character NameCharacterEntityNum 
Entity
Hex 
Entity
VULGAR FRACTION 1/4 ¼ &frac14; &#188;
VULGAR FRACTION 1/2 ½ &frac12; &#189;
VULGAR FRACTION 3/4 ¾ &frac34; &#190;
VULGAR FRACTION 1/3 ? -- &#8531;
VULGAR FRACTION 2/3 ? -- &#8532;
VULGAR FRACTION 1/5 ? -- &#8533;
VULGAR FRACTION 2/5 ? -- &#8354;
VULGAR FRACTION 3/5 ? -- &#8535;
VULGAR FRACTION 4/5 ? -- &#8536;
VULGAR FRACTION 1/6 ? -- &#8537;
VULGAR FRACTION 5/6 ? -- &#8538;
VULGAR FRACTION 1/8 ? -- &#8539;
VULGAR FRACTION 3/8 ? -- &#8540;
VULGAR FRACTION 5/8 ? -- &#8541;
VULGAR FRACTION 7/8 ? -- &#8342;

 

 

 

Common Statistics

-- means no HTML entity code exists and that a numeric code must be used.

 

Character NameCharacterEntityNum 
Entity
Hex 
Entity
LOWER CASE MU (Mean) μ &mu; &#956;
LOWER CASE SIGMA (Standard Deviation) σ &sigma; &#963;
LOWER CASE CHI χ &chi; &#967;
CAPITAL PI N-ARY PRODUCT &prod; &#8721;
N-ARY COPRODUCT (upside down capital pi) ? -- &#8720;

 

X-Bar, P-Hat and D-Bar

Some codes like that for x? (X-bar) are actually a combination of two codes - the base letter x plus a code for the line above (&#772: or  ?). Capital letter may need to be reduced in size to accomodate the placement of the combining diacritic.

Note on Safari: These symbols use combining characters and may not be correctly Safari 2 or other older browsers.

 

Statistical Symbol Codes
Character NameCharacterHTML Code
X-Bar (Average) x? x&#772;
P-Hat p? p&#770;
D-Bar D? <span style="font-size:80%">D</span>&#772;

 

 

Measurement Symbols

Common Symbols

 

Character NameCharacterEntityNum 
Entity
Hex 
Entity
DEGREE SYMBOL ° &deg; &#176;
MICRO MU SYMBOL µ &micro; &#181;
SINGLE PRIME (feet, degree minutes) &prime; &#8242;
DOUBLE PRIME (feet, degree minutes) &Prime;技术分享 &#8242;
PER MILLE (1/1000th) &permil; &#8240;

 

 

Calculus

Common Calculus Entity Codes

 

Character NameCharacterEntityNum 
Entity
Hex 
Entity
INTEGRAL &int; &#8747;
PARTIAL DIFFERENTIAL &part; &#8706;
INCREMENT (Difference or capital Delta) Δ &Delta; &#8710;
NABLA (Backward Difference, Grad or upside down triangle) &nabla; &#8711;

 

Additional Integral Symbols

These symbols have numeric entity codes only.

 

Character NameCharacterNum 
Entity
Hex 
Entity
DOUBLE INTEGRAL ? &#8748;
TRIPLE INTEGRAL ? &#8749;
QUADRUPLE INTEGRAL ? &#10764;
CONTOUR INTEGRAL &#8750;
SURFACE INTEGRAL ? &#8751;
VOLUME INTEGRAL ? &#8752;
CLOCKWISE INTEGRAL ? &#8753;
ANTICCLOCKWISE INTEGRAL ? &#10769;
CLOCKWISE CONTOUR INTEGRAL ? &#8754;
ANTICLOCKWISE CONTOUR INTEGRAL ? &#8755;

 

 

 

Letter Symbols

 

Character NameCharacterEntityNum 
Entity
Hex 
Entity
INFINITY (Sideways 8) &infin; &#8734;
ALEF INFINITY SYMBOL &alefsym; &#8501;
WEIERSTRASS POWER SET (Script Capital P) &weierp; &#8472;
IMAGINARY NUMBER (Blackletter I) &image; &#8242;
REAL NUMBER (Blackletter I) &real;技术分享 &#8242;
DOUBLE-STRUCK REAL NUMBER (Double R) ? -- &#8477;
COMPLEX NUMBERS (Double C) ? -- &#8450;
NATURAL NUMBERS (Double N) ? -- &#8469;
PRIME NUMBERS (Double P) ? -- &#8473;
RATIONAL NUMBERS (Double Q) ? -- &#8474;
INTEGERS (Double Z) ? -- &#8484;

 

 

Character NameCharacterEntityNum 
Entity
Hex 
Entity
FOR ALL (Upside-down A) &forall; &#8704;
COMPLEMENT (Thin C) ? -- &#8705;
THERE EXISTS (Backwards E) &exist; &#8707;
THERE DOES NOT EXIST (Backwards E with slash) ? -- &#8708;
EMPTY SET (O slash) &empty; &#8709;
NOT SYMBOL (Corner) ¬ &not; &#172;
TILDE (Alternate Not Symbol) ˜ &tilde; --
LOGICAL AND (Wedge or Upside down V Symbol) &and; &#8743;
LOGICAL OR (V Symbol) &or; &#8744;
XOR ? -- &#8891;
NAND ? -- &#8892;
NOR ? -- &#8893;
INTERSECTION (Cap or Upside Down U) &cap; &#8745;
UNION (Cup or U Symbol) &cup; &#8746;
ELEMENT OF &isin; &#8712;
NOT AN ELEMENT OF &notin; &#8713;
SMALL ELEMENT OF ? -- &#8714;
CONTAINS AS MEMBER &ni; &#8715;
DOES NOT CONTAIN AS MEMBER ? -- &#8716;
SMALL CONTAINS AS MEMBER ? -- &#8717;
SET MINUS ? -- &#8726;
SUBSET OF (Sideways U with cap to left) &sub; &#8834;
SUPERSET OF (Sideways U with cap to right) &sup; &#8835;
NOT A SUBSET OF (Subset with Slash) &nsub; &#8836;
NOT A SUPERSET OF (Superset with slash) ? -- &#8837;
SUBSET OF OR EQUAL TO (Subset with line below) &sube; &#8838;
SUPERSET OF OR EQUAL TO (Superset with line below) &supe; &#8839;
NEITHER A SUBSET OF NOR EQUAL TO ? -- &#8840;
NEITHER A SUPERSET OF NOR EQUAL TO ? -- &#8841;
SUBSET OF WITH NOT EQUAL TO ? -- &#8842;
SUPERSET OF WITH NOT EQUAL TO ? -- &#8843;
DIAMOND OPERATOR 
(Possibility)
? -- &#8900;
ASYMPTOTICALLY EQUAL TO 
One to one Correspondence
? -- &#8771;
NOT ASYMPTOTICALLY EQUAL TO ? -- &#8772;
MULTISET (U with arrow) ? -- &#8844;
MULTISET MULTIPLICATION (U with dot in center) ? -- &#8845;
MULTISET UNION (U with plus in center) ? -- &#8846;
DOUBLE SUBSET ? -- &#8912;
DOUBLE SUPERSET ? -- &#8913;
DOUBLE INTERSECTION ? -- &#8914;
DOUBLE UNION ? -- &#8915;
N-ARY LOGICAL AND ? -- &#8896;
N-ARY LOGICAL OR ? -- &#8897;
N-ARY INTERSECTION&cu ? -- &#8898;
N-ARY UNION ? -- &#8899;
CURLY LOGICAL OR ? -- &#8910;
CURLY LOGICAL AND ? -- &#8911;
CIRCLED PLUS (Direct Sum) &oplus; &#8853;
CIRCLED TIMES (Vector Product) &otimes; &#8855;
CIRCLED MINUS ? -- &#8854;
CIRCLED DIVISION SLASH ? -- &#8856;

 

Other Element Of Symbols

 

ELEMENT OF WITH LONG HORIZONTAL STROKE ? &#8946;
ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE ? &#8947;
SMALL ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE ? &#8948;
ELEMENT OF WITH DOT ABOVE ? &#8949;
ELEMENT OF WITH OVERBAR ? &#8950;
SMALL ELEMENT OF WITH OVERBAR ? &#8951;
ELEMENT OF WITH UNDERBAR ? &#8952;
ELEMENT OF WITH TWO HORIZONTAL STROKES ? &#8953;
CONTAINS WITH LONG HORIZONTAL STROKE ? &#8954;
CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE ? &#8955;
SMALL CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE ? &#8956;
CONTAINS WITH OVERBAR ? &#8957;
SMALL CONTAINS WITH OVERBAR ? &#8958;
NOTATION BAG MEMBERSHIP ? &#8959;

 

 

Geometric Symbols

Note: The entity code for the Angle Symbol (∠) is &ang; and the code for the perpendicular angle (⊥) is&perp;
Otherwise, these symbols have numeric codes only.

Angles and Lines

 

Character NameCharacterNum 
Entity
Hex 
Entity
RIGHT ANGLE &#8735;
ANGLE 
Entity Code = &ang;
&#8736;
MEASURED ANGLE ? &#8737;
SPHERICAL ANGLE ? &#8738;
DIVIDES &#8739;
DOES NOT DIVIDE ? &#8740;
PARALLEL TO &#8741;
NOT PARALLEL TO ? &#8742;
RIGHT ANGLE WITH ARC ? &#8894;
RIGHT TRIANGLE &#8895;
UP TACK (Perpendicular) 
Entity Code = &perp;
&#8869;
RIGHT TACK ? &#8866;
LEFT TACK ? &#8867;
DOWN TACK ? &#8868;

 

Logical Proofs

Note: The entity code for the Therefore Symbol (∴) is &there4;. Otherwise, these symbols have numeric codes only.

 

Character NameCharacterNum 
Entity
Hex 
Entity
THEREFORE (Triangular Dots) 
Entity Code = &there4;
&#8756;
BECAUSE (Upside down Triangular Dots) &#8757;
PROPORTIONAL TO 
Entity Code = &prop;
&#8733;
END OF PROOF (solid rectangle) ? &#8718;

 

 

 

Common Equivalence and Proportion Operators

Common Equivalence Operators

 

Character NameCharacterEntityNum 
Entity
Hex 
Entity
NOT EQUALS &ne; &#8800;
APPROXIMATELY EQUAL &cong; &#8773;
ALMOST EQUAL (ASYMPTOTIC) &asymp; &#8776;
NOT ALMOST EQUAL TO ? &#8777;
TILDE SIMILAR TO &sim; &#8764;
IDENTICAL TO (three lines) &equiv; &#8801;
NOT IDENTICAL TO ? &#8802;

 

Other Equivalence Symbols

 

 

STRICTLY EQUIVALENT TO ? &#8803;
NOT IDENTICAL TO ? &#8802;
LESS-THAN OVER EQUAL TO &#8806;
GREATER-THAN OVER EQUAL TO &#8807;
LESS-THAN BUT NOT EQUAL TO ? &#8808;
GREATER-THAN BUT NOT EQUAL TO ? &#8809;
MUCH LESS-THAN ? &#8810;
MUCH GREATER-THAN ? &#8811;
BETWEEN ? &#8812;
NOT EQUIVALENT TO ? &#8813;
NOT LESS-THAN &#8814;
NOT GREATER-THAN &#8815;
NEITHER LESS-THAN NOR EQUAL TO ? &#8816;
NEITHER GREATER-THAN NOR EQUAL TO ? &#8817;
LESS-THAN OR EQUIVALENT TO ? &#8818;
GREATER-THAN OR EQUIVALENT TO ? &#8819;
NEITHER LESS-THAN NOR EQUIVALENT TO ? &#8820;
NEITHER GREATER-THAN NOR EQUIVALENT TO ? &#8821;
LESS-THAN OR GREATER-THAN ? &#8822;
GREATER-THAN OR LESS-THAN ? &#8823;
NEITHER LESS-THAN NOR GREATERTHAN ? &#8824;
NEITHER GREATER-THAN NOR LESSTHAN ? &#8825;
NOT TILDE ? &#8769;
MINUS TILDE ? &#8770;
ASYMPTOTICALLY EQUAL TO ? &#8771;
NOT ASYMPTOTICALLY EQUAL TO ? &#8772;
APPROXIMATELY BUT NOT ACTUALLY EQUAL TO ? &#8774;
NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO ? &#8775;
NOT ALMOST EQUAL TO ? &#8777;
ALMOST EQUAL OR EQUAL TO ? &#8778;
TRIPLE TILDE ? &#8779;
ALL EQUAL TO &#8780;

 

 

原文地址:http://blog.csdn.net/snowdust/article/details/5895593

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!