Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2004, 02:46 PM
Authorized User
 
Join Date: Jul 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default turning ' into ’

I’m creating a from that allows users to enter in answers to questions. It will be common for them to use apostrophes in their answers, like “I’m planning to attend University next year”. Those apostrophes are causing havoc as ASP is treating them like pieces of the code; I’m looking for a way to automatically change all ‘s into #8217;.

I tried using Server.HTMLEncode(FromElementName) but this didn’t do it. It worked for &s, turning them into &.

In desperation I also tried Server.URLEncode(FromElementName). This also didn’t work.


Any ideas how I can do this?

.m


 
Old August 20th, 2004, 03:35 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi m,
Code:
Replace(stringName, "'", "#8217")
Will do what you want, but, how is this causing problems in your code - if it's with dynamic query building, IMHO you're better of replacing the apostrophes by doubling them up before adding them to your queries...

Code:
Replace(stringName, "'", "''")
That way data stored in a database remains as it was initially submitted & you can query / export it etc without having to worry about reverting any changes you made.

HTH,

Chris
 
Old August 20th, 2004, 10:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Bigmish,

Also, forget not the quote in red.
Code:
Replace(stringName, "'", "''")
_________________________
- Vijay G
Strive for Perfection
 
Old August 20th, 2004, 12:04 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks Vijay,

Have ammended the posting.

Chris

 
Old August 21st, 2004, 11:32 AM
Authorized User
 
Join Date: Jul 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Gents, worked like a charm. Hadn’t known about that function. It’s a handy one.

Best, M







Similar Threads
Thread Thread Starter Forum Replies Last Post
Turning XML into HTML poole@daveandkate.fsnet.c XSLT 2 June 8th, 2006 05:20 PM
Turning Siblings into Children wolfie78uk XSLT 3 December 22nd, 2005 08:33 AM
Turning strings into bits...help patpicos BOOK: Beginning Java 2 2 March 29th, 2005 06:09 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
Turning element text into XPath Kael XSLT 5 October 14th, 2004 03:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.