> When trying to add characters like � and �, my SQL 7
> server tells me I have not enclosed my strings properly.
> I'm assuming the tilde is breaking it. Any way around
> that, other than looking for that character and replacing
> it, with say the HTML equivalent that works? Or will I
> just have to do a replace() on the string?
If you are using CF 5, a quick way to replace special characters (like smart
quotes when cutting and pasting from Word) is to use user-defined functions.
The one we adapted from a couple of sources is this:
<CFSCRIPT>
function SafeChars(textin) {
bad_chars="(tm),�,"",",",',',-,-,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�
,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�
,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�";
good_chars="&##153;, ,",",",‘,’,—,&nda
sh;,Æ,Á,Â,À,Å,Ã,Ä,Ç,Ð
,É,Ê,È,Ë,Í,Î,Ì,Ï,Ñ,
Ó,Ô,Ò,Ø,Õ,Ö,Þ,Ú,Û,
Ù,Ü,Ý,á,â,æ,à,å,ã,
ä,ç,é,ê,è,ð,ë,í,î,&igr
ave;,ï,ñ,ó,ô,ò,ø,õ,ö,&szl
ig;,þ,ú,û,ù,ü,ý,ÿ,¡,£
,¤,¥,¦,§,¨,©,ª,«,¬,­,®
;,¯,°,±,²,³,´,µ,¶,·,¸
;,¹,º,»,¼,½,¾,¿,×,÷
,¢";
/* Replace Content with updated Content */
text_out=ReplaceList(textin, bad_chars, good_chars);
return text_out;
}
</CFSCRIPT>
You can put this UDF at the top of the page (or include it if you want to
use it multiple times) and then use a SQL statement like this:
INSERT INTO mytable
(myfield1, myfield2)
VALUES
('#SafeChars(mytext1)#', '#SafeChars(mytext2)#')
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Simon Park Computer Systems Management, Inc.
Director, E-Business 205 South Whiting Street #201
Ph: 703-823-4300 x119 Alexandria, VA 22304
fax: 703-823-4301 http://www.csmi.com
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists