str = "\x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a".force_encoding('ASCII-8BIT')
puts CGI.escape str
=> "%124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A"
More Related Contents:
- Test if string is a number in Ruby on Rails
- Converting camel case to underscore case in ruby
- How to extract URL parameters from a URL with Ruby or Rails?
- Converting string from snake_case to CamelCase in Ruby
- How to check if a string is a valid date
- How to prevent browser page caching in Rails
- ActiveRecord: size vs count
- OO Design in Rails: Where to put stuff
- ruby/ruby on rails memory leak detection
- How can I uninstall Ruby on ubuntu?
- How do I ‘validate’ on destroy in rails
- How do i work with two different databases in rails with active records?
- How to get a query string from a URL in Rails
- Using Rails Migration on different database than standard “production” or “development”
- Rails Console: reload! not reflecting changes in model files? What could be possible reason?
- How would you parse a url in Ruby to get the main domain?
- no such file to load — readline
- counter_cache with has_many :through
- Heroku not sending email with Gmail SMTP
- How can I specify a local gem in my Gemfile?
- How to set default values in Rails?
- What is the right way to override a setter method in Ruby on Rails?
- How do I use gems with Ubuntu?
- “gem install rails” fails with DNS error
- How do you do relative time in Rails?
- Rails – Sort by join table data
- strong parameters permit all attributes for nested attributes
- Installing Ruby on Rails – Mac OS Lion
- Ruby: Create range of dates
- Unable to install MySQL2 gem on Windows 7