Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

** Replacing Characters: ’ – “ ??? **

Status
Not open for further replies.

jonnywah

Programmer
Feb 7, 2004
80
0
0
US
I am trying to write a VB function to replace these awkward characters in a string:

Replace with Single Quote ('):
’

Replace with DASH (-):
–

Replace with 2 Single Quotes (''):
“ (or) â€

Replace with 3 Periods ( ... ):
…


Function CleanString(strInput)
mySTemp = Replace(Replace(Replace(Replace(Replace(strInput,"–", "-"), "“", "''"), "â€", "''"), "…", " ... "), "'", "''")
CleanString = mySTemp
End Function


I am super tired, and I can't get this function to work. Please help. Any suggestions or information would be appreciated. Thank you in advance.
 
Genimuse,

I understand your point with hidden characters, but there will not be any hidden characters (eg. vertical tab) in ’, – , “, â€, or ….

I still can't figure how to play with the value of a text area. I can't even use trim!
 
from what it looks like you're trying to call this code client side.

post your code please.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
How do you know there aren't any hidden characters?

And as Drex points out, we're exclusively talking about server side stuff here, where Trim works just fine. Are you talking about client-side VBScript and not ASP?
 
There shouldn't be any hidden characters because the ’, – , “, â€, and … come from cutting and pasting out of a MS Word document.

I am using the VB function in ASP (ie. server side code). The code does work but oddly enough I can never get any function to work on a text area value. Even doing a simple trim, eg:

Desc = Trim(Request.Form("txtDesc"))

doesn't work. I don't know how to get around this except to use Javascript to "clean" the data before submitting it to the server side. Unfortunately I couldn't get JS to work here since € is not recognized.
 
I still don't have a working solution ... arrgghh
 
That's because -- and this is my last post on the subject -- there are hidden characters in your text. Microsoft Word text is FULL of hidden characters.

Best of luck, man.
 
Genimuse and DreXor,

I appreciate all your help and input. I'll keep trying and if I ever figure it out, I'll let you know. Thank you! Have a great weekend!

 
javascript will support the character if you use the character code.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
DreXor,

I couldn't get it to work in Javascript. Javascript kept giving an string not terminated (which shouldn't be happening) for — .



 
you have to handle for the quotes : replace ' to ''

do you happen to have a sample of this page with the NON-functional issues and text in it available online?

it would greatly help to see the issue at hand in first person vs getting it after you've interpreted it, and posted it and this forum's handlers have had their way with the raw text.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Javascript indicating that a string isn't terminated would lead me to believe that there's a hidden carriage return character or similar in the string, making Javascript think it's a new line.

Wait, it can't be hidden characters, you already said so. I forgot. Must be something else.

(I did post here again! Weird!)
 
or possibly can u post a link to a copy of the MS Word document in contention ?

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top