String utility methods #
HTML_ENTITY_LUT | = | { 'quot' => '"', # quote 'amp' => '&', # amperstand 'lt' => '<', # less-than 'gt' => '>', # greater-than 'nbsp' => ' ', # nonbreaking space 'cent' => '[cent]', # cent 'pound' => '[pound]', # pound 'yen' => '[yen]', # yen 'brvbar' => '|', # broken vertical bar 'copy' => '(c)', # copyright 'laquo' => '<<', # left-pointing double angle quotation mark 'not' => '[not]', # not 'reg' => '(r)', # registered trademark 'deg' => '[degree]', # degree 'plusmn' => '[plus or minus]', # plus or minus 'sup2' => '[squared]', # superscript 2, squared 'sup3' => '[cubed]', # superscript 3, cubed 'acute' => "'", # accute accent 'micro' => "[mu]", # micro (aka mu) 'raquo' => ">>", # right-pointing double angle quotation mark 'frac14' => '[1/4]', # vulgar fraction one quarter 'frac34' => '[3/4]', # vulgar fraction three quarters 'times' => 'x', # times 'aelig' => '[ae]', # latin small ligature ae 'divide' => '/', # divide 'OElig' => '[OE]', # latin capital ligature OE 'oelig' => '[oe]', # latin small ligature OE 'fnof' => '[f()]', # latin small f with hook = function = florin 'circ' => '^', # circumflex 'tilde' => '~', # small tilde 'trade' => '[tm]', # trademark 'ndash' => '-', # en dash 'mdash' => '--', # em dash } |
HTML Entity Lookup Table
source of this LUT: http://www.htmlcodetutorial.com/characterentities_famsupp_69.html |
|
UNICODE_LUT | = | { 732 => '~', # small tilde 733 => '~', # double-small acute tilde 913 => '[ALPHA]', # capital alpha 914 => '[BETA]', # capital beta 915 => '[GAMMA]', # capital gamma 916 => '[DELTA]', # capital delta 917 => '[EPSILON]', # capital epsilon 918 => '[ZETA]', # capital zeta 919 => '[ETA]', # capital eta 920 => '[THETA]', # capital theta 921 => '[IOTA]', # capital iota 922 => '[KAPPA]', # capital kappa 923 => '[LAMDA]', # capital lamda 924 => '[MU]', # capital mu 925 => '[NU]', # capital nu 926 => '[XI]', # capital xi 927 => '[OMICRON]', # capital omicron 928 => '[PI]', # capital pi 929 => '[RHO]', # capital rho 931 => '[SIGMA]', # capital sigma 932 => '[TAU]', # capital tau 933 => '[UPSILON]', # capital upsilon 934 => '[PHI]', # capital phi 935 => '[CHI]', # capital chi 936 => '[PSI]', # capital psi 937 => '[OMEGA]', # capital omega 945 => '[alpha]', # small alpha 946 => '[beta]', # small beta 947 => '[gamma]', # small gamma 948 => '[delta]', # small delta 949 => '[epsilon]', # small epsilon 950 => '[zeta]', # small zeta 951 => '[eta]', # small eta 952 => '[theta]', # small theta 953 => '[iota]', # small iota 954 => '[kappa]', # small kappa 955 => '[lamda]', # small lamda 956 => '[mu]', # small mu 957 => '[nu]', # small nu 958 => '[xi]', # small xi 959 => '[omicron]', # small omicron 960 => '[pi]', # small pi 961 => '[rho]', # small rho 962 => '[final]', # small final 963 => '[sigma]', # small sigma 964 => '[tau]', # small tau 965 => '[upsilon]', # small upsilon 966 => '[phi]', # small phi 967 => '[chi]', # small chi 968 => '[psi]', # small psi 969 => '[omega]', # small omega 8208 => '-', # hyphen 8211 => '--', # en dash 8212 => '--', # em dash 8213 => '-', # horizontal bar 8216 => "`", # left single quotation mark 8217 => "'", # right single quotation mark 8218 => ',', # single low-9 quotation mark 8219 => '`', # single high-reversed-9 quotation mark 8220 => '``', # left double quotation mark 8221 => '"', # right double quotation mark 8222 => ',,', # double low-9 quotation mark 8226 => '*', # bullet 8242 => "'", # prime 8243 => "''", # double prime 8249 => '<', # single left-pointing angle quotation mark 8250 => '>', # single right-pointing angle quotation mark 8252 => '!!', # double exclamation point 8250 => '/', # fraction slash 8355 => '[franc]', # french franc sign 8356 => '[lira]', # lira sign 8359 => '[peseta]', # peseta sign 8453 => '[c/o]', # care of 8364 => '[euro]', # euro sign 8470 => '[numero]', # numero sign 8482 => '[tm]', # trademark sign 8486 => '[ohm]', # ohm sign 8494 => '[est.]', # estimated symbol 8539 => '[1/8]', # vulgar fraction one eighth 8540 => '[3/8]', # vulgar fraction three eighths 8541 => '[5/8]', # vulgar fraction five eighths 8542 => '[7/8]', # vulgar fraction seven eighths 8722 => '-', # minus sign 8729 => '*', # bullet operator 8730 => '[sqrt]', # square root 8734 => '[inf]', # infinity 8735 => '[right angle]', # right angle 8745 => '[intersection]', # intersection 8747 => '[integral]', # integal 8776 => '[almost equal to]', # almost equal to 8800 => '[not equal to]', # not equal to 8801 => '[identical to]', # identical to 8804 => '[< or =]', # less-than or equal to 8805 => '[> or =]', # greater-than or equal to 64257 => '[fl]', # latin small ligature fi 64258 => '[FL]', # latin small ligature fi } |
Unicode Entity Lookup Table
source of this LUT: http://www.pemberley.com/janeinfo/latin1.html |
Escape ’%’ characters in this string. Returns self.
Example:
a = 'a%b'.escape_format! a.escape_format! a #=> 'a%%b'
return a copy of this string with HTML special characters escaped
Example:
str = '<b>Rip & "Burn"</b>'.escape_html str #=> "<b>Rip &amp "Burn"</b>"
Return copy of string with lines reflowed for the given terminal width.
Example:
str = "this is a really long string it won't fit" str.reflow(22) #=> "this is a really long\nstring it won't fit"
Return copy of string with all HTML tags stripped.
Example:
"<a href='sadf'>blargh</a>".strip_tags #=> 'blargh'