Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Easy to Remember Unicode Map for Ruby
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
db
lib
log
spec
.gitignore
.rspec
README.md
Rakefile
ruby-glyph.gemspec

README.md

Glyph

Easy to use unicode characters in ruby

A list of all the glyphs is here: http://viatropos.github.com/glyph

Install

gem install ruby-glyph

Only tested (and should only work) on Ruby 1.9 because of the encoding functionality.

API

RubyGlyph.glyph(:sum)   #=> ∑
RubyGlyph.entity(:sum)  #=> ∑
RubyGlyph.decimal(:sum) #=> ∑
RubyGlyph.hex(:sum)     #=> ∑
RubyGlyph.source(:sum)  #=> u"\u2211"
RubyGlyph.keys          #=> [:sum, ...]

Use "UTF-8" Encoding in HTML

In your HTML document, you must set the character set to "UTF-8" (which is what it usually is):

HTML5:

<meta charset='UTF-8' />

HTML4:

<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />

Interesting ruby tidbit: you can't write "∑" in a string in a .rb file by default... you have to add this to the top of your file:

# encoding: UTF-8

puts ""

Use html_safe in Rails

If you try to render the glyph in an HTML page, like RubyGlyph.glyph(:sum), it will show up all crazy. Instead, do this:

%cite= "#{RubyGlyph.entity(:copyright)} Our Company".html_safe
<cite>© Our Company</cite>

Compiled from:

Helpful articles:


MIT License. By Lance Pollard.

Something went wrong with that request. Please try again.