Escape the back slash

(33…35).each{|a| p a.chr}
=> “!”
=> “”"
=> “#”

I’m trying to insert single characters into a database, one at a time…

“INSERT INTO database, place ( ID, chr), (NULL, ‘#{a.chr}’)”

(This sql query is for example)

34.chr=> ’ " ’
I hope to get =>’ " ’

I solved the problem above but now i have ran into “” inserting unto a
database gives me the error
’ “”

That backslash is for displaying purposes, it is not “there”.

(33…35).each { |x| p x.chr.to_s.size }
1
1
1

If I convert the char to string, then multiply it, it stays the same
length as the others:

(33…35).each { |x| p (x.chr.to_s*2).size }
2
2
2

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs