From: Meino Christian Cramer Date: 2003-08-30T16:05:18+09:00 Subject: Re: Quoted string problem From: Hugh Sasse Staff Elec Eng Subject: Re: Quoted string problem Date: Sat, 30 Aug 2003 08:29:11 +0900 Hi Hugh, Thanks for your reply ! > > > Hi, > > > > These database is in a "flat ascii file": Each broadcaster gets one > > line of 294 charcters. Each "column" is only sperated from the others > > by known offsets. > [...] > > Generally: how can I process input to escape "special" characters > > Regexp.escape(aString) > > > before I send them to mysqld? > > > > (In perl there is a command called "quotemeta", which does the > > Regexp.escape is also known as: Regexp.quote(aString) > > > Hugh > > This is (nearly) exactly for what I have searched for... Unfortunately the "'" is not escaped and this character is that, what make my headache... I have a broadcaster called "N'Djamena". The "'" in its name confuses the string sent to mySQL... I tried (with irb) the following. But I cannot figure out, what game ruby is playing with me... ;) (in irb:) >> a="N'Djamena" => "N'Djamena" >> a => "N'Djamena" >> a.gsub( "'","X") => "NXDjamena" >> a.gsub( "'","\'") => "N'Djamena" >> a.gsub( "'","\\\'") => "NDjamenaDjamena" >> What is happening here. I exspected the last expression to be evalutated to "N\'Djamena". But I am a ruby newbie, so ruby is right and me is wrong....but why and what ? By the way: I tried DBI but it seems not 1.8.0-ready ? I got a lot of errors... Now I am using ruby-mysql-0.2.1.tar.gz, which works fine... beside my "special-char" problems. I am happy, if you could give me an additional tip/hint... Thank you very much in advance ! Keep hacking! Meino