I have a string containing byte data.
How can I perform an in-place conversion to ascii string?
views:
1577answers:
2
+1
A:
You can do so via using base64 which is a fairly universal way.
require 'base64'
str = Base64.encode64(data)
Phil
2009-02-05 11:19:50
data needs to be convertible to String for this to work. Try, for example:irb(main):002:0> Base64.encode64(1234)TypeError: can't convert Fixnum into String
Brent.Longborough
2009-02-05 14:38:36