June25

Euro Symbol in Ruby

I have been using a ruby based functional testing tool that I wrote to test a clients web application. The web application uses different currency symbols of which most were quite happily handled by default within ruby.

However the Euro symbol was a bit more of a problem. Just pasting in the € symbol didn’t work out so instead I had to dig around for some help and I found this useful ruby-forum topic where someone had a similar problem: Euro currency symbol

Right at the bottom I found what I was looking for. A way to replace the euro symbol in my string with some ruby code that could generate the right symbol:

   # The string I wanted to use to set a drop
   # down select option on a form
   "HUB  € DAH Argus (Mid)"  

   # The solution
   euro_symbol = [8364].pack("U")
   "HUB #{euro_symbol} DAH Argus (Mid)" 

Posted by kingsleyh | Filed in Ruby |

Sorry, comments are closed for this article.