From: Rich Date: 2004-06-27T02:14:11+09:00 Subject: Re: SQLite-Ruby and "other chrs" You could URL encode it... ... I've spent a bit of time in the past working with FORM submitted information that has to be made 'safe' before it can be stored or even before it can be brought into a scripted environment... and encoding it the way it would need to be to be in a URL has always worked. So... require "cgi" bad_string="a's"+'d"f' puts CGI::escape(bad_string) # prints out: a%27sd%22f That should be a little easier. -Richard ----- Original Message ----- From: "Meino Christian Cramer" To: ; Sent: Saturday, June 26, 2004 10:42 AM Subject: Re: SQLite-Ruby and "other chrs" > From: Rich > Subject: Re: SQLite-Ruby and "other chrs" > Date: Sat, 26 Jun 2004 23:58:13 +0900 > > Other way around: > > I have a string containing a backslash. > How can I replace that backslash with nothing? > > Or: > How can I store a string in a variable, which looks like this > > "R.N" + "'" + "Djamena" > > ( start- and end-" not included ). > > When trying this: > > a="\"R.N\" + \"'\" + \"Djamena\"" > > I get naturelamente exactly this > > \"R.N\" + \"'\" + \"Djamena\" > > as contents of the string. The " weren't recognized as escaped as in > (shell scripting / bash ) > > echo "This the value of a \"string\"" > > This is the value of a "string". > > Regexp.escape also seems not to fit this problem... > > > I require the module 'base64' and then encode64 everything that could have > > funky characters before I put it in the DB. > > > > Obviously to get it out you'd want to decode64 everything that was encoded. > > > > This will let you put binary files into sqlite as well, since there's no > > 'BLOB' column type. > > > > whyTHEluckySTIFF's tutorial got me started... > > > > http://whytheluckystiff.net/articles/aQuickGuideToSQLite.html > > > > -Richard > > > > ----- Original Message ----- > > From: "Meino Christian Cramer" > > To: "ruby-talk ML" > > Sent: Saturday, June 26, 2004 6:05 AM > > Subject: SQLite-Ruby and "other chrs" > > > > > > > Hi, > > > > > > a problem with "other chars" hits me... :) > > > > > > I try to read a database of shortwave broadcasters (formatted ascii) > > > into a SQLIte-Ruby database. > > > > > > The initialization is ok, but from time to time the population of the > > > db breaks, cause some broadcasters station names include invalid > > > chars like > > > > > > R.N'Djamena > > > > > > and the "'" kills everything. > > > > > > Escaping that character in the textfile, which is read to populate > > > the db, doesn't work, cause "\'" ist read as "\" + "'", which > > > again is one "'" to much. > > > > > > With mysql there was a method called ".Mysql_escape_string" which > > > does this job. In the SQLite and SQLite-Ruby docs I haven't found > > > anything similiar... > > > > > > How can I solve this problem? > > > > > > Kind regards and thank you very much in advance, > > > Meino > > > > > > > >