Convert unicode characters to HTML entities in Ruby
def entities( str ) converted = [] str.split(//).collect { |c| converted << ( c[0] > 127 ? "&##{c[0]};" : c ) } converted.join('') end
DZone Snippets > brainpipe > entities
12382 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
def entities( str ) converted = [] str.split(//).collect { |c| converted << ( c[0] > 127 ? "&##{c[0]};" : c ) } converted.join('') end