При написании очередного мегапроекта встала непосильная задача - сделать красивости средствами яваскрипта. Суть проблемы заключалась в том, чтобы использовать всякие вкусности типа
, –
и т.д. средствами JavaScript при заполнении динамических списков SELECT
. Требовалось заменить короткий знак - (минус) на более длинный и красивый – (–).
Порывшись в сети, нашёл, что можно использовать функцию String.fromCharCode()
для получения UNICODE-символа по его коду. Список символов (сущностей) HTML нашёлся по адресу http://www.w3.org/TR/html4/sgml/entities.html, правда, в несколько непотребном виде. Однако, мою проблему со списками удалось решить:
... // Создание элемента Option с заменой в названии минуса на – var opt = new Option(name.replace(/-/g, String.fromCharCode(0x2013))); ... |
После некоторых махинаций со списком от W3C получилась такая табличка:
Символ | Сущность | Сущность-код | Использование в JavaScript |
---|---|---|---|
Пробелы | |||
|
  |
String.fromCharCode(0x00A0) |
|
  |
  |
String.fromCharCode(0x2002) |
|
  |
  |
String.fromCharCode(0x2003) |
|
Спецсимволы (HTML) | |||
" | " |
" |
String.fromCharCode(0x0022) |
& | & |
& |
String.fromCharCode(0x0026) |
< | < |
< |
String.fromCharCode(0x003C) |
> | > |
> |
String.fromCharCode(0x003E) |
Œ | Œ |
Œ |
String.fromCharCode(0x0152) |
œ | œ |
œ |
String.fromCharCode(0x0153) |
Š | Š |
Š |
String.fromCharCode(0x0160) |
š | š |
š |
String.fromCharCode(0x0161) |
Ÿ | Ÿ |
Ÿ |
String.fromCharCode(0x0178) |
ˆ | ˆ |
ˆ |
String.fromCharCode(0x02C6) |
˜ | ˜ |
˜ |
String.fromCharCode(0x02DC) |
  |
  |
String.fromCharCode(0x2009) |
|
| ‌ |
‌ |
String.fromCharCode(0x200C) |
| ‍ |
‍ |
String.fromCharCode(0x200D) |
| ‎ |
‎ |
String.fromCharCode(0x200E) |
| ‏ |
‏ |
String.fromCharCode(0x200F) |
– | – |
– |
String.fromCharCode(0x2013) |
— | — |
— |
String.fromCharCode(0x2014) |
‘ | ‘ |
‘ |
String.fromCharCode(0x2018) |
’ | ’ |
’ |
String.fromCharCode(0x2019) |
‚ | ‚ |
‚ |
String.fromCharCode(0x201A) |
“ | “ |
“ |
String.fromCharCode(0x201C) |
” | ” |
” |
String.fromCharCode(0x201D) |
„ | „ |
„ |
String.fromCharCode(0x201E) |
† | † |
† |
String.fromCharCode(0x2020) |
‡ | ‡ |
‡ |
String.fromCharCode(0x2021) |
‰ | ‰ |
‰ |
String.fromCharCode(0x2030) |
‹ | ‹ |
‹ |
String.fromCharCode(0x2039) |
› | › |
› |
String.fromCharCode(0x203A) |
€ | € |
€ |
String.fromCharCode(0x20AC) |
¡ | ¡ |
¡ |
String.fromCharCode(0x00A1) |
¢ | ¢ |
¢ |
String.fromCharCode(0x00A2) |
£ | £ |
£ |
String.fromCharCode(0x00A3) |
¤ | ¤ |
¤ |
String.fromCharCode(0x00A4) |
¥ | ¥ |
¥ |
String.fromCharCode(0x00A5) |
¦ | ¦ |
¦ |
String.fromCharCode(0x00A6) |
§ | § |
§ |
String.fromCharCode(0x00A7) |
¨ | ¨ |
¨ |
String.fromCharCode(0x00A8) |
© | © |
© |
String.fromCharCode(0x00A9) |
ª | ª |
ª |
String.fromCharCode(0x00AA) |
« | « |
« |
String.fromCharCode(0x00AB) |
» | » |
» |
String.fromCharCode(0x00BB) |
¬ | ¬ |
¬ |
String.fromCharCode(0x00AC) |
| ­ |
­ |
String.fromCharCode(0x00AD) |
® | ® |
® |
String.fromCharCode(0x00AE) |
¯ | ¯ |
¯ |
String.fromCharCode(0x00AF) |
° | ° |
° |
String.fromCharCode(0x00B0) |
± | ± |
± |
String.fromCharCode(0x00B1) |
² | ² |
² |
String.fromCharCode(0x00B2) |
³ | ³ |
³ |
String.fromCharCode(0x00B3) |
´ | ´ |
´ |
String.fromCharCode(0x00B4) |
µ | µ |
µ |
String.fromCharCode(0x00B5) |
¶ | ¶ |
¶ |
String.fromCharCode(0x00B6) |
· | · |
· |
String.fromCharCode(0x00B7) |
¸ | ¸ |
¸ |
String.fromCharCode(0x00B8) |
¹ | ¹ |
¹ |
String.fromCharCode(0x00B9) |
º | º |
º |
String.fromCharCode(0x00BA) |
¼ | ¼ |
¼ |
String.fromCharCode(0x00BC) |
½ | ½ |
½ |
String.fromCharCode(0x00BD) |
¾ | ¾ |
¾ |
String.fromCharCode(0x00BE) |
¿ | ¿ |
¿ |
String.fromCharCode(0x00BF) |
Стрелочки, указатели, посылатели | |||
← | ← |
← |
String.fromCharCode(0x2190) |
↑ | ↑ |
↑ |
String.fromCharCode(0x2191) |
→ | → |
→ |
String.fromCharCode(0x2192) |
↓ | ↓ |
↓ |
String.fromCharCode(0x2193) |
↔ | ↔ |
↔ |
String.fromCharCode(0x2194) |
↵ | ↵ |
↵ |
String.fromCharCode(0x21B5) |
⇐ | ⇐ |
⇐ |
String.fromCharCode(0x21D0) |
⇑ | ⇑ |
⇑ |
String.fromCharCode(0x21D1) |
⇒ | ⇒ |
⇒ |
String.fromCharCode(0x21D2) |
⇓ | ⇓ |
⇓ |
String.fromCharCode(0x21D3) |
⇔ | ⇔ |
⇔ |
String.fromCharCode(0x21D4) |
Пунктуация | |||
• | • |
• |
String.fromCharCode(0x2022) |
… | … |
… |
String.fromCharCode(0x2026) |
′ | ′ |
′ |
String.fromCharCode(0x2032) |
″ | ″ |
″ |
String.fromCharCode(0x2033) |
‾ | ‾ |
‾ |
String.fromCharCode(0x203E) |
⁄ | ⁄ |
⁄ |
String.fromCharCode(0x2044) |
Похожие на буквы красявости | |||
℘ | ℘ |
℘ |
String.fromCharCode(0x2118) |
ℑ | ℑ |
ℑ |
String.fromCharCode(0x2111) |
ℜ | ℜ |
ℜ |
String.fromCharCode(0x211C) |
™ | ™ |
™ |
String.fromCharCode(0x2122) |
ℵ | ℵ |
ℵ |
String.fromCharCode(0x2135) |
Греческий алфавит | |||
Α | Α |
Α |
String.fromCharCode(0x0391) |
Β | Β |
Β |
String.fromCharCode(0x0392) |
Γ | Γ |
Γ |
String.fromCharCode(0x0393) |
Δ | Δ |
Δ |
String.fromCharCode(0x0394) |
Ε | Ε |
Ε |
String.fromCharCode(0x0395) |
Ζ | Ζ |
Ζ |
String.fromCharCode(0x0396) |
Η | Η |
Η |
String.fromCharCode(0x0397) |
Θ | Θ |
Θ |
String.fromCharCode(0x0398) |
Ι | Ι |
Ι |
String.fromCharCode(0x0399) |
Κ | Κ |
Κ |
String.fromCharCode(0x039A) |
Λ | Λ |
Λ |
String.fromCharCode(0x039B) |
Μ | Μ |
Μ |
String.fromCharCode(0x039C) |
Ν | Ν |
Ν |
String.fromCharCode(0x039D) |
Ξ | Ξ |
Ξ |
String.fromCharCode(0x039E) |
Ο | Ο |
Ο |
String.fromCharCode(0x039F) |
Π | Π |
Π |
String.fromCharCode(0x03A0) |
Ρ | Ρ |
Ρ |
String.fromCharCode(0x03A1) |
Σ | Σ |
Σ |
String.fromCharCode(0x03A3) |
Τ | Τ |
Τ |
String.fromCharCode(0x03A4) |
Υ | Υ |
Υ |
String.fromCharCode(0x03A5) |
Φ | Φ |
Φ |
String.fromCharCode(0x03A6) |
Χ | Χ |
Χ |
String.fromCharCode(0x03A7) |
Ψ | Ψ |
Ψ |
String.fromCharCode(0x03A8) |
Ω | Ω |
Ω |
String.fromCharCode(0x03A9) |
α | α |
α |
String.fromCharCode(0x03B1) |
β | β |
β |
String.fromCharCode(0x03B2) |
γ | γ |
γ |
String.fromCharCode(0x03B3) |
δ | δ |
δ |
String.fromCharCode(0x03B4) |
ε | ε |
ε |
String.fromCharCode(0x03B5) |
ζ | ζ |
ζ |
String.fromCharCode(0x03B6) |
η | η |
η |
String.fromCharCode(0x03B7) |
θ | θ |
θ |
String.fromCharCode(0x03B8) |
ι | ι |
ι |
String.fromCharCode(0x03B9) |
κ | κ |
κ |
String.fromCharCode(0x03BA) |
λ | λ |
λ |
String.fromCharCode(0x03BB) |
μ | μ |
μ |
String.fromCharCode(0x03BC) |
ν | ν |
ν |
String.fromCharCode(0x03BD) |
ξ | ξ |
ξ |
String.fromCharCode(0x03BE) |
ο | ο |
ο |
String.fromCharCode(0x03BF) |
π | π |
π |
String.fromCharCode(0x03C0) |
ρ | ρ |
ρ |
String.fromCharCode(0x03C1) |
ς | ς |
ς |
String.fromCharCode(0x03C2) |
σ | σ |
σ |
String.fromCharCode(0x03C3) |
τ | τ |
τ |
String.fromCharCode(0x03C4) |
υ | υ |
υ |
String.fromCharCode(0x03C5) |
φ | φ |
φ |
String.fromCharCode(0x03C6) |
χ | χ |
χ |
String.fromCharCode(0x03C7) |
ψ | ψ |
ψ |
String.fromCharCode(0x03C8) |
ω | ω |
ω |
String.fromCharCode(0x03C9) |
ϑ | ϑ |
ϑ |
String.fromCharCode(0x03D1) |
ϒ | ϒ |
ϒ |
String.fromCharCode(0x03D2) |
ϖ | ϖ |
ϖ |
String.fromCharCode(0x03D6) |
Физика, математика | |||
∀ | ∀ |
∀ |
String.fromCharCode(0x2200) |
∂ | ∂ |
∂ |
String.fromCharCode(0x2202) |
∃ | ∃ |
∃ |
String.fromCharCode(0x2203) |
∅ | ∅ |
∅ |
String.fromCharCode(0x2205) |
∇ | ∇ |
∇ |
String.fromCharCode(0x2207) |
∈ | ∈ |
∈ |
String.fromCharCode(0x2208) |
∉ | ∉ |
∉ |
String.fromCharCode(0x2209) |
∋ | ∋ |
∋ |
String.fromCharCode(0x220B) |
∏ | ∏ |
∏ |
String.fromCharCode(0x220F) |
∑ | ∑ |
∑ |
String.fromCharCode(0x2211) |
− | − |
− |
String.fromCharCode(0x2212) |
∗ | ∗ |
∗ |
String.fromCharCode(0x2217) |
√ | √ |
√ |
String.fromCharCode(0x221A) |
∝ | ∝ |
∝ |
String.fromCharCode(0x221D) |
∞ | ∞ |
∞ |
String.fromCharCode(0x221E) |
∠ | ∠ |
∠ |
String.fromCharCode(0x2220) |
∧ | ∧ |
∧ |
String.fromCharCode(0x2227) |
∨ | ∨ |
∨ |
String.fromCharCode(0x2228) |
∩ | ∩ |
∩ |
String.fromCharCode(0x2229) |
∪ | ∪ |
∪ |
String.fromCharCode(0x222A) |
∫ | ∫ |
∫ |
String.fromCharCode(0x222B) |
∴ | ∴ |
∴ |
String.fromCharCode(0x2234) |
∼ | ∼ |
∼ |
String.fromCharCode(0x223C) |
≅ | ≅ |
≅ |
String.fromCharCode(0x2245) |
≈ | ≈ |
≈ |
String.fromCharCode(0x2248) |
≠ | ≠ |
≠ |
String.fromCharCode(0x2260) |
≡ | ≡ |
≡ |
String.fromCharCode(0x2261) |
≤ | ≤ |
≤ |
String.fromCharCode(0x2264) |
≥ | ≥ |
≥ |
String.fromCharCode(0x2265) |
⊂ | ⊂ |
⊂ |
String.fromCharCode(0x2282) |
⊃ | ⊃ |
⊃ |
String.fromCharCode(0x2283) |
⊄ | ⊄ |
⊄ |
String.fromCharCode(0x2284) |
⊆ | ⊆ |
⊆ |
String.fromCharCode(0x2286) |
⊇ | ⊇ |
⊇ |
String.fromCharCode(0x2287) |
⊕ | ⊕ |
⊕ |
String.fromCharCode(0x2295) |
⊗ | ⊗ |
⊗ |
String.fromCharCode(0x2297) |
⊥ | ⊥ |
⊥ |
String.fromCharCode(0x22A5) |
⋅ | ⋅ |
⋅ |
String.fromCharCode(0x22C5) |
⌈ | ⌈ |
⌈ |
String.fromCharCode(0x2308) |
⌉ | ⌉ |
⌉ |
String.fromCharCode(0x2309) |
⌊ | ⌊ |
⌊ |
String.fromCharCode(0x230A) |
⌋ | ⌋ |
⌋ |
String.fromCharCode(0x230B) |
〈 | ⟨ |
〈 |
String.fromCharCode(0x2329) |
〉 | ⟩ |
〉 |
String.fromCharCode(0x232A) |
Геометрические фигуры | |||
◊ | ◊ |
◊ |
String.fromCharCode(0x25CA) |
♠ | ♠ |
♠ |
String.fromCharCode(0x2660) |
♣ | ♣ |
♣ |
String.fromCharCode(0x2663) |
♥ | ♥ |
♥ |
String.fromCharCode(0x2665) |
♦ | ♦ |
♦ |
String.fromCharCode(0x2666) |
Кракозябры | |||
À | À |
À |
String.fromCharCode(0x00C0) |
Á | Á |
Á |
String.fromCharCode(0x00C1) |
 |  |
 |
String.fromCharCode(0x00C2) |
à | à |
à |
String.fromCharCode(0x00C3) |
Ä | Ä |
Ä |
String.fromCharCode(0x00C4) |
Å | Å |
Å |
String.fromCharCode(0x00C5) |
Æ | Æ |
Æ |
String.fromCharCode(0x00C6) |
Ç | Ç |
Ç |
String.fromCharCode(0x00C7) |
È | È |
È |
String.fromCharCode(0x00C8) |
É | É |
É |
String.fromCharCode(0x00C9) |
Ê | Ê |
Ê |
String.fromCharCode(0x00CA) |
Ë | Ë |
Ë |
String.fromCharCode(0x00CB) |
Ì | Ì |
Ì |
String.fromCharCode(0x00CC) |
Í | Í |
Í |
String.fromCharCode(0x00CD) |
Î | Î |
Î |
String.fromCharCode(0x00CE) |
Ï | Ï |
Ï |
String.fromCharCode(0x00CF) |
Ð | Ð |
Ð |
String.fromCharCode(0x00D0) |
Ñ | Ñ |
Ñ |
String.fromCharCode(0x00D1) |
Ò | Ò |
Ò |
String.fromCharCode(0x00D2) |
Ó | Ó |
Ó |
String.fromCharCode(0x00D3) |
Ô | Ô |
Ô |
String.fromCharCode(0x00D4) |
Õ | Õ |
Õ |
String.fromCharCode(0x00D5) |
Ö | Ö |
Ö |
String.fromCharCode(0x00D6) |
× | × |
× |
String.fromCharCode(0x00D7) |
Ø | Ø |
Ø |
String.fromCharCode(0x00D8) |
Ù | Ù |
Ù |
String.fromCharCode(0x00D9) |
Ú | Ú |
Ú |
String.fromCharCode(0x00DA) |
Û | Û |
Û |
String.fromCharCode(0x00DB) |
Ü | Ü |
Ü |
String.fromCharCode(0x00DC) |
Ý | Ý |
Ý |
String.fromCharCode(0x00DD) |
Þ | Þ |
Þ |
String.fromCharCode(0x00DE) |
ß | ß |
ß |
String.fromCharCode(0x00DF) |
à | à |
à |
String.fromCharCode(0x00E0) |
á | á |
á |
String.fromCharCode(0x00E1) |
â | â |
â |
String.fromCharCode(0x00E2) |
ã | ã |
ã |
String.fromCharCode(0x00E3) |
ä | ä |
ä |
String.fromCharCode(0x00E4) |
å | å |
å |
String.fromCharCode(0x00E5) |
æ | æ |
æ |
String.fromCharCode(0x00E6) |
ç | ç |
ç |
String.fromCharCode(0x00E7) |
è | è |
è |
String.fromCharCode(0x00E8) |
é | é |
é |
String.fromCharCode(0x00E9) |
ê | ê |
ê |
String.fromCharCode(0x00EA) |
ë | ë |
ë |
String.fromCharCode(0x00EB) |
ì | ì |
ì |
String.fromCharCode(0x00EC) |
í | í |
í |
String.fromCharCode(0x00ED) |
î | î |
î |
String.fromCharCode(0x00EE) |
ï | ï |
ï |
String.fromCharCode(0x00EF) |
ð | ð |
ð |
String.fromCharCode(0x00F0) |
ñ | ñ |
ñ |
String.fromCharCode(0x00F1) |
ò | ò |
ò |
String.fromCharCode(0x00F2) |
ó | ó |
ó |
String.fromCharCode(0x00F3) |
ô | ô |
ô |
String.fromCharCode(0x00F4) |
õ | õ |
õ |
String.fromCharCode(0x00F5) |
ö | ö |
ö |
String.fromCharCode(0x00F6) |
÷ | ÷ |
÷ |
String.fromCharCode(0x00F7) |
ø | ø |
ø |
String.fromCharCode(0x00F8) |
ù | ù |
ù |
String.fromCharCode(0x00F9) |
ú | ú |
ú |
String.fromCharCode(0x00FA) |
û | û |
û |
String.fromCharCode(0x00FB) |
ü | ü |
ü |
String.fromCharCode(0x00FC) |
ý | ý |
ý |
String.fromCharCode(0x00FD) |
þ | þ |
þ |
String.fromCharCode(0x00FE) |
ÿ | ÿ |
ÿ |
String.fromCharCode(0x00FF) |
ƒ | ƒ |
ƒ |
String.fromCharCode(0x0192) |