Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How to generate characters by a function which works like the Esc + a + ESC

In[24]:= CharacterRange["a","z"]
Out[24]= {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}

How to batch convert them to Greek Letters just like that done by this way Esc + a + Esc ... something like this, a function works,

In[25]:= CharacterRange["\[Alpha]","\[Zeta]"]
Out[25]= {\[Alpha],\[Beta],\[Gamma],\[Delta],\[CurlyEpsilon],\[Zeta]}

EnglishToGreekRange["a", "z"]

Comes out

{\[Alpha],\[Beta],\[Chi]...}
share|improve this question

2 Answers 2

up vote 8 down vote accepted

That's a good question, though perhaps difficult to answer. The input aliases for these letters are stored not in the InputAliases option of the $FrontEnd object but rather in the UnicodeCharacters.tr file. Surely they are loaded into the Front End but I do not know the location of that data, and as such I cannot think of a clean way to access that mapping. Perhaps someone like John Fultz will take the time to answer this question and provide the correct look-up method.

If it is acceptable to allow conversion of only the Greek letters than could be accomplished by manually building a conversion table. Here is such a table for your convenience:

aliastable = 
 {"a" -> "α", "b" -> "β", "g" -> "γ", "d" -> "δ", "e" -> "ϵ", "z" -> "ζ",
 "et" -> "η", "th" -> "θ", "i" -> "ι", "k" -> "κ", "l" -> "λ", "m" -> "μ",
 "n" -> "ν", "x" -> "ξ", "om" -> "ο", "p" -> "π", "r" -> "ρ", "s" -> "σ",
 "t" -> "τ", "u" -> "υ", "ph" -> "ϕ", "ch" -> "χ", "ps" -> "ψ", "o" -> "ω",
 "di" -> "ϝ", "ko" -> "ϟ", "sti" -> "ϛ", "sa" -> "ϡ", "A" -> "Α", "B" -> "Β",
 "G" -> "Γ", "D" -> "Δ", "E" -> "Ε", "Z" -> "Ζ", "Et" -> "Η", "Th" -> "Θ",
 "I" -> "Ι", "K" -> "Κ", "L" -> "Λ", "M" -> "Μ", "N" -> "Ν", "X" -> "Ξ",
 "Om" -> "Ο", "P" -> "Π", "R" -> "Ρ", "S" -> "Σ", "T" -> "Τ", "U" -> "Υ",
 "cU" -> "ϒ", "Ph" -> "Φ", "Ch" -> "Χ", "Ps" -> "Ψ", "O" -> "Ω", "Di" -> "Ϝ",
 "Ko" -> "Ϟ", "Sti" -> "Ϛ", "Sa" -> "Ϡ"};

Now:

CharacterRange["a", "z"] /. aliastable

You can access a limited set of additional input aliases, including user-created ones, with:

CurrentValue["InputAliases"]

Here is a larger table with every letter in the Special Characters palette:

bigtable = {"a" -> "α", "b" -> "β", "g" -> "γ", "d" -> "δ", "e" -> "ϵ", "z" -> "ζ", "et" -> "η", "th" -> "θ", "i" -> "ι", "k" -> "κ", "l" -> "λ", "m" -> "μ", "n" -> "ν", "x" -> "ξ", "om" -> "ο", "p" -> "π", "r" -> "ρ", "s" -> "σ", "t" -> "τ", "u" -> "υ", "ph" -> "ϕ", "ch" -> "χ", "ps" -> "ψ", "o" -> "ω", "di" -> "ϝ", "ko" -> "ϟ", "sti" -> "ϛ", "sa" -> "ϡ", "A" -> "Α", "B" -> "Β", "G" -> "Γ", "D" -> "Δ", "E" -> "Ε", "Z" -> "Ζ", "Et" -> "Η", "Th" -> "Θ", "I" -> "Ι", "K" -> "Κ", "L" -> "Λ", "M" -> "Μ", "N" -> "Ν", "X" -> "Ξ", "Om" -> "Ο", "P" -> "Π", "R" -> "Ρ", "S" -> "Σ", "T" -> "Τ", "U" -> "Υ", "cU" -> "ϒ", "Ph" -> "Φ", "Ch" -> "Χ", "Ps" -> "Ψ", "O" -> "Ω", "Di" -> "Ϝ", "Ko" -> "Ϟ", "Sti" -> "Ϛ", "Sa" -> "Ϡ", "sca" -> "", "scb" -> "", "scc" -> "", "scd" -> "", "sce" -> "ℯ", "scf" -> "", "scg" -> "ℊ", "sch" -> "", "sci" -> "", "scj" -> "", "sck" -> "", "scl" -> "ℓ", "scm" -> "", "scn" -> "", "sco" -> "ℴ", "scp" -> "", "scq" -> "", "scr" -> "", "scs" -> "", "sct" -> "", "scu" -> "", "scv" -> "", "scw" -> "", "scx" -> "", "scy" -> "", "scz" -> "", "scA" -> "", "scB" -> "ℬ", "scC" -> "", "scD" -> "", "scE" -> "ℰ", "scF" -> "ℱ", "scG" -> "", "scH" -> "ℋ", "scI" -> "ℐ", "scJ" -> "", "scK" -> "", "scL" -> "ℒ", "scM" -> "ℳ", "scN" -> "", "scO" -> "", "scP" -> "", "scQ" -> "", "scR" -> "ℛ", "scS" -> "", "scT" -> "", "scU" -> "", "scV" -> "", "scW" -> "", "scX" -> "", "scY" -> "", "scZ" -> "", "goa" -> "", "gob" -> "", "goc" -> "", "god" -> "", "goe" -> "", "gof" -> "", "gog" -> "", "goh" -> "", "goi" -> "", "goj" -> "", "gok" -> "", "gol" -> "", "gom" -> "", "gon" -> "", "goo" -> "", "gop" -> "", "goq" -> "", "gor" -> "", "gos" -> "", "got" -> "", "gou" -> "", "gov" -> "", "gow" -> "", "gox" -> "", "goy" -> "", "goz" -> "", "goA" -> "", "goB" -> "", "goC" -> "ℭ", "goD" -> "", "goE" -> "", "goF" -> "", "goG" -> "", "goH" -> "ℌ", "goI" -> "ℑ", "goJ" -> "", "goK" -> "", "goL" -> "", "goM" -> "", "goN" -> "", "goO" -> "", "goP" -> "", "goQ" -> "", "goR" -> "ℜ", "goS" -> "", "goT" -> "", "goU" -> "", "goV" -> "", "goW" -> "", "goX" -> "", "goY" -> "", "goZ" -> "ℨ", "dsa" -> "", "dsb" -> "", "dsc" -> "", "dsd" -> "", "dse" -> "", "dsf" -> "", "dsg" -> "", "dsh" -> "", "dsi" -> "", "dsj" -> "", "dsk" -> "", "dsl" -> "", "dsm" -> "", "dsn" -> "", "dso" -> "", "dsp" -> "", "dsq" -> "", "dsr" -> "", "dss" -> "", "dst" -> "", "dsu" -> "", "dsv" -> "", "dsw" -> "", "dsx" -> "", "dsy" -> "", "dsz" -> "", "dsA" -> "", "dsB" -> "", "dsC" -> "", "dsD" -> "", "dsE" -> "", "dsF" -> "", "dsG" -> "", "dsH" -> "", "dsI" -> "", "dsJ" -> "", "dsK" -> "", "dsL" -> "", "dsM" -> "", "dsN" -> "", "dsO" -> "", "dsP" -> "", "dsQ" -> "", "dsR" -> "", "dsS" -> "", "dsT" -> "", "dsU" -> "", "dsV" -> "", "dsW" -> "", "dsX" -> "", "dsY" -> "", "dsZ" -> "", "a`" -> "à", "a'" -> "á", "a^" -> "â", "a~" -> "ã", "au" -> "ă", "a\"" -> "ä", "a-" -> "ā", "ao" -> "å", "ae" -> "æ", "c'" -> "ć", "cv" -> "č", "c," -> "ç", "e`" -> "è", "e'" -> "é", "e^" -> "ê", "eu" -> "ĕ", "e\"" -> "ë", "e-" -> "ē", "i`" -> "ì", "i'" -> "í", "i^" -> "î", "iu" -> "ĭ", "i\"" -> "ï", "d-" -> "ð", "l/" -> "ł", "n~" -> "ñ", "o`" -> "ò", "o'" -> "ó", "o^" -> "ô", "o~" -> "õ", "o\"" -> "ö", "o''" -> "ő", "o/" -> "ø", "sv" -> "š", "u`" -> "ù", "u'" -> "ú", "u^" -> "û", "u\"" -> "ü", "u''" -> "ű", "y'" -> "ý", "y\"" -> "ÿ", "thn" -> "þ", "A`" -> "À", "A'" -> "Á", "A^" -> "Â", "A~" -> "Ã", "Au" -> "Ă", "A\"" -> "Ä", "A-" -> "Ā", "Ao" -> "Å", "AE" -> "Æ", "C'" -> "Ć", "Cv" -> "Č", "C," -> "Ç", "E`" -> "È", "E'" -> "É", "E^" -> "Ê", "Eu" -> "Ĕ", "E\"" -> "Ë", "E-" -> "Ē", "I`" -> "Ì", "I'" -> "Í", "I^" -> "Î", "Iu" -> "Ĭ", "I\"" -> "Ï", "D-" -> "Ð", "L/" -> "Ł", "N~" -> "Ñ", "O`" -> "Ò", "O'" -> "Ó", "O^" -> "Ô", "O~" -> "Õ", "O\"" -> "Ö", "O''" -> "Ő", "O/" -> "Ø", "OE" -> "Œ", "Sv" -> "Š", "U`" -> "Ù", "U'" -> "Ú", "U^" -> "Û", "U\"" -> "Ü", "U''" -> "Ű", "Y'" -> "Ý", "Thn" -> "Þ", "sz" -> "ß", "$a" -> "", "$b" -> "", "$c" -> "", "$d" -> "", "$e" -> "", "$f" -> "", "$g" -> "", "$h" -> "", "$i" -> "", "$j" -> "", "$k" -> "", "$l" -> "", "$m" -> "", "$n" -> "", "$o" -> "", "$p" -> "", "$q" -> "", "$r" -> "", "$s" -> "", "$t" -> "", "$u" -> "", "$v" -> "", "$w" -> "", "$x" -> "", "$y" -> "", "$z" -> "", "$A" -> "", "$B" -> "", "$C" -> "", "$D" -> "", "$E" -> "", "$F" -> "", "$G" -> "", "$H" -> "", "$I" -> "", "$J" -> "", "$K" -> "", "$L" -> "", "$M" -> "", "$N" -> "", "$O" -> "", "$P" -> "", "$Q" -> "", "$R" -> "", "$S" -> "", "$T" -> "", "$U" -> "", "$V" -> "", "$W" -> "", "$X" -> "", "$Y" -> "", "$Z" -> "", "cc" -> "", "ee" -> "", "ii" -> "", "jj" -> "", "pp" -> "", "gg" -> "", "inf" -> "∞", "mi" -> "µ", "mho" -> "℧", "Ang" -> "Å", "hb" -> "ℏ", "al" -> "ℵ", "be" -> "ℶ", "gi" -> "ℷ", "da" -> "ℸ", "wp" -> "℘", "es" -> "∅", "deg" -> "°", "␣␣" -> " ", "*" -> "×", "div" -> "÷", "sqrt" -> "√", "cross" -> "", "+-" -> "±", "-+" -> "∓", "sum" -> "∑", "prod" -> "∏", "del" -> "∇", "dd" -> "", "pd" -> "∂", "DD" -> "", "int" -> "∫", "cint" -> "∮", "ccint" -> "∲", "cccint" -> "∳", "->" -> "", ":>" -> "", "not" -> "¬", "and" -> "∧", "nand" -> "⊼", "or" -> "∨", "nor" -> "⊽", "xor" -> "⊻", "=>" -> "", "fa" -> "∀", "ex" -> "∃", "!ex" -> "∄", "st" -> "∍", "tf" -> "∴", "sq" -> "", "sc" -> "∘", "c+" -> "⊕", "c-" -> "⊖", "c." -> "⊙", "c*" -> "⊗", "dia" -> "⋄", "." -> "·", "star" -> "⋆", "\\" -> "∖", "^" -> "⋀", "v" -> "⋁", "un" -> "⋃", "inter" -> "⋂", "coprod" -> "∐", "|" -> "", "lf" -> "⌊", "rf" -> "⌋", "lc" -> "⌈", "rc" -> "⌉", "[[" -> "〚", "]]" -> "〛", "<" -> "〈", ">" -> "〉", "l|" -> "", "r|" -> "", "l||" -> "", "r||" -> "", ":" -> "∶", "!=" -> "≠", "==" -> "", "===" -> "≡", "!===" -> "≢", ".=" -> "≐", "prop" -> "∝", "!~=" -> "≄", "~=" -> "≃", "~==" -> "≅", "!~==" -> "≇", "!~" -> "≁", "~" -> "∼", "~~" -> "≈", "!~~" -> "≉", "!=~" -> "", "=~" -> "≂", "!h=" -> "", "h=" -> "≏", "!<" -> "≮", "!>" -> "≯", "!</" -> "", "</" -> "⩽", ">/" -> "⩾", "!>/" -> "", "!<=" -> "≰", "<=" -> "≤", ">=" -> "≥", "!>=" -> "≱", "!<~" -> "≴", "<~" -> "≲", ">~" -> "≳", "!>~" -> "≵", "!sub" -> "⊄", "sub" -> "⊂", "sup" -> "⊃", "!sup" -> "⊅", "!sub=" -> "⊈", "sub=" -> "⊆", "sup=" -> "⊇", "!sup=" -> "⊉", "!elem" -> "∉", "elem" -> "∈", "mem" -> "∋", "!mem" -> "∌", "!|" -> "", "␣|" -> "", "␣||" -> "∥", "!||" -> "∦", "<-" -> "←", "␣->" -> "→", "<->" -> "↔", "<=>" -> "⇔", "<-->" -> "⟷", "<==>" -> "⟺", "␣<=" -> "⇐", "␣=>" -> "⇒", "<--" -> "⟵", "<==" -> "⟸", "-->" -> "⟶", "==>" -> "⟹", "vec" -> "⇀", "equi" -> "⇌", "lT" -> "⊣", "rT" -> "⊢", "uT" -> "⊥", "dT" -> "⊤", "fsq" -> "■", "fsci" -> "", "fci" -> "●", "esq" -> "□", "esci" -> "◦", "eci" -> "○", "fvssq" -> "▪", "fssq" -> "◼", "gsq" -> "", "gci" -> "", "evssq" -> "▫", "essq" -> "◻", "*5" -> "★", "*6" -> "✶", "math" -> "", ":-)" -> "☺", ":-|" -> "", ":-(" -> "☹", ":-@" -> "", "wolf" -> "", "-" -> "–", "--" -> "—", "hy" -> "‐", "cent" -> "¢", "d?" -> "¿", "d!" -> "¡", "#" -> "", "g<<" -> "«", "g>>" -> "»", "bu" -> "•", "dg" -> "†", "ddg" -> "‡", "'" -> "′", "''" -> "″", "`" -> "‵", "``" -> "‶", "hc" -> "̌", "bv" -> "̆", "dbv" -> "̑", "cd" -> "̧", "['" -> "‘", "]'" -> "’", "[\"" -> "“", "]\"" -> "”", "..." -> "…", "hline" -> "─", "vline" -> "│", "u(" -> "︶", "o(" -> "︵", "u[" -> "⎵", "o[" -> "⎴", "u{" -> "︸", "o{" -> "︷", "space" -> "␣", "cl" -> "⌘", "ret" -> "↵", "alt" -> "", "cmd" -> "", "ctrl" -> "", "␣del" -> "", "ent" -> "", "␣esc" -> "", "m1" -> "", "m2" -> "", "opt" -> "", "sh" -> "", "spc" -> "", "␣ret" -> "", "tab" -> "", "kb" -> "", "[" -> "", "]" -> "", "spl" -> "", "pl" -> "", "cont" -> "", "esc" -> ""};

Generated with:

nb = NotebookGet @ NotebookOpen @ 
      FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "Palettes", 
       "SpecialCharacters.nb"}];

Cases[nb, {_[_[str1_String, ___], ___], _String, 
   str2_String?(StringMatchQ[#, "*\[EscapeKey]*\[EscapeKey]*"] &)} :> (StringTake[
     str2, {3, -3}] -> str1), -1]
share|improve this answer
    
It's ok, for a mannualy conversion rules is easily to build via get all these greek letter not by just typing them. Thanks. –  HyperGroups May 16 '13 at 9:03
    
@HyperGroups I'm glad this helps you. If you use the bigtable you should probably hit it with Dispatch for best performance. –  Mr.Wizard May 16 '13 at 10:56

Here's a function that might help:

Clear[escapify];
Attributes[escapify] = {Listable};
escapify[s_String] :=
  NotebookWrite[SelectedNotebook[], StringJoin[
    "\\" <> "[AliasDelimiter]" <> # <> "\\" <> "[AliasDelimiter]" & /@ Characters[s]]];

This takes each character in a string (or list of strings) and puts it into a new cell with escapes around it. When you type ESC in the front-end, Mathematica turns it into an \[AliasDelimiter]. This function splits of the slash from the front so the front end doesn't try to interpret it until it's written into the new cell.

escapify[CharacterRange["a", "z"]];

αβχδϵφγηιϕκλμνοπθρστυvωξψζ
share|improve this answer
    
Interesting work-around. I wonder if I can improve this... –  Mr.Wizard May 16 '13 at 22:58
    
@Mr.Wizard You're welcome to improve it. It's definitely a bit rough around the edges at the moment. –  wxffles May 16 '13 at 23:06
    
I don't know that I can. The thing is I don't really understand when/how the conversion is made. For example, this doesn't work, but it is immediately converted if you start editing the output cell: CellPrint@Cell[RowBox@{StringJoin[{"\[AliasDelimiter]", "a", "\[AliasDelimiter]"}]}, "Input"]; from this I thought the input had to be interactive but as I said NotebookWrite is a nice work-around. I don't know how to use that without actually generating output though, which I see as undesirable. –  Mr.Wizard May 16 '13 at 23:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.