• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

Ruby HTML Entity Problem

New to Ruby and am wondering how to get the following to print just the degree symbol...

require 'htmlentities'
coder = HTMLEntities.new
puts coder.decode('°')

Open in new window


Currently the command line (Windows) output is: °

Thanks!
0
R_O_B
Asked:
R_O_B
  • 3
  • 3
1 Solution
 
JESiiCommented:
What version of Ruby are you running? And what version of HTMLEntities is installed? And what platform?

I just tried this with Ruby 1.9.2, htmlentities 4.3.0, Linux and it worked just fine - got the degree symbol printed.
0
 
R_O_BAuthor Commented:
Was solved with
puts coder.decode('&deg;').encode(Encoding.find('<Whatever-Windows-Uses>'))

Open in new window


Thanks!
0
 
JESiiCommented:
Sorry; now I see that you're on Windows... I'll check that, too.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
JESiiCommented:
Interesting; I normally run my ruby stuff under cygwin (www.cygwin.com) and in that environment, I again get only the single degree character; no Â. What's your specific windows environment?
0
 
R_O_BAuthor Commented:
No cygwin, just Ruby192 on Windows 7.
0
 
R_O_BAuthor Commented:
Answered on StackOverflow.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now