Is there a more efficient way to convert a string such as
"abcdef" to "abcdef" ?
Currently I am doing the following:
a="abcdef"
a.delete!("&#")
ar = a.split(';')
arn = ar.collect { |s| Integer(s) }
s = arn.pack("U*")
puts "s=#{s.inspect}"
I need to do this for thousands of records that are
loaded into a database, so I'm a bit concerned
about repeatedly executing all of the above code.
Thanks
You could write the conversion routine in C, which is efficient for
customised byte manipulation.
There may be an efficient Ruby solution, but this is one tool which
could be used for the job.
smitty wrote:
···
Is there a more efficient way to convert a string such as
"abcdef" to "abcdef" ?
Currently I am doing the following:
a="abcdef"
a.delete!("&#")
ar = a.split(';')
arn = ar.collect { |s| Integer(s) }
s = arn.pack("U*")
puts "s=#{s.inspect}"
I need to do this for thousands of records that are
loaded into a database, so I'm a bit concerned
about repeatedly executing all of the above code.
Thanks