MySQL2 and non text into varchar

This might not be the right place to put this, if it’s not I do
apologize, but I hope maybe someone here can at least point me in the
right direction.

I’m currently creating a module to download sports box scores from
websites (in HTML) that will insert the data into databases using regex
and loops so that the data can be further analyzed.

I ran into a problem with the names of some players having non letter
punctuation (commas, periods, apostrophes, dashes, etc…), which I
hadn’t fully expected. I solved the issue of ‘getting’ the names with
the regex, but mysql rejects the inserts into a varchar field with this
non text characters. Right now my solution is to remove the non text
characters on the insert of the athletes name, but then the name is
stored improperly. I know PHP has an ‘escape string’ function that
handles these things automatically. Is there something built in to ruby
to handle something like this. If there isn’t is there a way to write a
gsub that will replace these non text characters with a \ before them,
all at once?

i.e if it’s a “,”, “.”, “-” replace it with , , . , - or do i have to
do each one individually?

On Tue, Oct 16, 2012 at 7:53 AM, Ja Ma [email protected] wrote:

… mysql rejects the inserts into a varchar field with this
non text characters.

No. You need to provide more context (actual error message, the
output of show create table , etc.).

There’s no intrinsic problem in storing punctuation characters in a
MySQL VARCHAR column.