Module: Lipsiadmin::Utils::HtmlEntities
- Included in:
- Controller::PdfBuilder, Mailer::PdfBuilder
- Defined in:
- lib/utils/html_entities.rb
Overview
Convert common utf-8 chars to html entities, this is beautifull (but the code not) for servers that don’t have utf-8 fonts for java. Is a dead simple workaround for avoid losing time.
Instance Method Summary collapse
-
#encode_entities(text) ⇒ Object
Convert common utf-8 chars to html entities.
Instance Method Details
#encode_entities(text) ⇒ Object
Convert common utf-8 chars to html entities
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/utils/html_entities.rb', line 9 def encode_entities(text) map = { "'" => "#145", # ' This is converted for java "’" => "rsquo", # ’ "°" => "deg", # ° "€" => "euro", # € "–" => "ndash", # – "©" => "copy", # © "«" => "laquo", # « "®" => "reg", # ® "»" => "raquo", # » "à" => "agrave", # à "À" => "Agrave", # À "á" => "aacute", # á "Á" => "Aacute", # á "â" => "acirc", # â "Â" => "Acirc", # Â "ä" => "auml", # ä "Ä" => "Auml", # ä "Æ" => "AElig", # Æ "æ" => "aelig", # æ "ç" => "ccedil", # ç "Ç" => "Ccedil", # Ç "è" => "egrave", # è "È" => "Egrave", # È "é" => "eacute", # é "É" => "Eacute", # É "ê" => "ecirc", # ê "Ê" => "Ecirc", # Ê "ë" => "euml", # ë "Ë" => "Euml", # Ë "ì" => "igrave", # ì "Ì" => "Igrave", # Ì "î" => "icirc", # î "Î" => "Icirc", # Î "ï" => "iuml", # ï "Ï" => "Iuml", # Ï "ô" => "ocirc", # ô "Ô" => "Ocirc", # Ô "ö" => "ouml", # ö "Ö" => "Ouml", # Ö "ò" => "ograve", # ò "Ò" => "Ograve", # ò "ù" => "ugrave", # ù "Ù" => "Ugrave", # Ù "û" => "ucirc", # û "Û" => "Ucirc", # Û "ü" => "uuml", # ü "Ü" => "Uuml" # Ü } map.each { |k,v| text.gsub!("#{k}", "&#{v};") } return text end |