473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Replace double quotes (") with single quotes (')

gar
Hi,

I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code

text= Replace(text, """", "'"

This works fine (for normal double quotes).The problem comes in when you copy a double quote from MS Word and paste it in the text box. What happens is the double quote becomes slanted (“) so my code above can't filter it. I tried to do this

text= Replace(text, "““","'")

but what happens is that after typing this in visual studio, vb automatically converts it to the normal double quote ("). I already tried

text= Replace(text, chr(34), "'") ' 34 is the ascii of double quotes (")

but still, it won't work. I can't seem to find the ascii of the slanted double quotes, they somehow look all the same to me

Is there a work around for this

Thanks.
Nov 20 '05 #1
7 20831
Gar,
I can't seem to find the ascii of the slanted double quotes,
they somehow look all the same to me There is no ASCII for a Double Quote, there is an ANSI for Double Quote,
however I would recommend Unicode instead, so as to avoid
internationalization issues (read different ANSI code pages). You can use
Character Map under "Start - Programs - Accessories - System Tools" to find
the Unicode code point for the different typographic quote chars available.

Try something like:

' what most people think of quote chars
Const Apostrophe As Char = ChrW(&H27) ' single quotes
Const Quote As Char = ChrW(&H22) ' double quotes

' various typographic quote characters
Const LeftSingleQuote As Char = ChrW(&H2018)
Const RightSingleQuote As Char = ChrW(&H2019)
Const LeftDoubleQuote As Char = ChrW(&H201C)
Const RightDoubleQuote As Char = ChrW(&H201D)

' other typographic quote characters (international)
' Note: HP48 uses these for delimiters
Const LeftPointingDoubleAngleQuote As Char = ChrW(&HAB)
Const RightPointingDoubleAngleQuote As Char = ChrW(&HBB)

' other typographic quote characters (international)
Const SingleLow9Quote As Char = ChrW(&H201A)
Const SingleHighReversed9Quote As Char = ChrW(&H201B)
Const DoubleLow9Quote As Char = ChrW(&H201E)

' simulate cut & paste from Word
Dim text As String = LeftDoubleQuote & "This is a test" &
RightDoubleQuote

text = text.Replace(LeftDoubleQuote, Apostrophe)
text = text.Replace(RightDoubleQuote, Apostrophe)

Note I included most of the various typographic quote characters. The four
that are commonly used by Word (in the US) are LeftSingleQuote,
RightSingleQuote, LeftDoubleQuote and RightDoubleQuote.

For details on quote chars & typographic quote chars see:
http://www.amazon.com/exec/obidos/tg...67152?v=glance

Hope this helps
Jay
"gar" <an*******@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com... Hi,

I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code:
text= Replace(text, """", "'")

This works fine (for normal double quotes).The problem comes in when you copy a double quote from MS Word and paste it in the text box. What happens
is the double quote becomes slanted (") so my code above can't filter it. I
tried to do this:
text= Replace(text, """","'")

but what happens is that after typing this in visual studio, vb automatically converts it to the normal double quote ("). I already tried:
text= Replace(text, chr(34), "'") ' 34 is the ascii of double quotes (")

but still, it won't work. I can't seem to find the ascii of the slanted double quotes, they somehow look all the same to me
Is there a work around for this?

Thanks.

Nov 20 '05 #2
Gar,
I should add that there is no ASCII Left Double Quote, as ASCII is a 7 bit
code point (chars 0 to 127), while ANSI is 8 bit code point (chars 0 to
255). Where chars 0 to 127 are the same as ASCII, while chars 128 to 255
vary depending on local.

Unicode allows for millions of code points, so the need for code pages found
in ANSI is eliminated...

Also: Chr & Asc deals with ANSI code points, while ChrW & AscW deals with
Unicode code points.

Hope this helps
Jay

"gar" <an*******@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
Hi,

I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code:
text= Replace(text, """", "'")

This works fine (for normal double quotes).The problem comes in when you copy a double quote from MS Word and paste it in the text box. What happens
is the double quote becomes slanted (") so my code above can't filter it. I
tried to do this:
text= Replace(text, """","'")

but what happens is that after typing this in visual studio, vb automatically converts it to the normal double quote ("). I already tried:
text= Replace(text, chr(34), "'") ' 34 is the ascii of double quotes (")

but still, it won't work. I can't seem to find the ascii of the slanted double quotes, they somehow look all the same to me
Is there a work around for this?

Thanks.

Nov 20 '05 #3
gar
Thank you very much. It worked :)
Nov 20 '05 #4
Hi Jay,

Will you point me for a good link for those Unicodes, I see you have them
mostly all or is it from a book?

Cor
Nov 20 '05 #5
Cor,

Will any of these help?

http://www.nefec.org/UPM/sansi.htm
http://www.unicode.org/charts/
http://www.jpsoft.com/help/index.htm?codesref.htm

Thanks
MCN

"gar" <an*******@discussions.microsoft.com> wrote in message
news:71**********************************@microsof t.com...
Thank you very much. It worked :)

Nov 20 '05 #6
Cor,
I used Character Map & looked for them.

Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl...
Hi Jay,

Will you point me for a good link for those Unicodes, I see you have them
mostly all or is it from a book?

Cor

Nov 20 '05 #7
Hi Jay,

I never knew that this was possible.
Makes things again a lot easier.

:-)

Thanks

Cor
Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: girish | last post by:
In my XML document, some node attributes data contains both single quot and double quote characters, such as <input msg="Hello "World", What's up"/>. The double quotes are in form of escape...
6
by: G. | last post by:
This is an obvious bug in the String.Replace function: //load a XML string into a document XmlDocument doc = new XmlDocument(); doc.LoadXml("<test id='' />"); //Obtain the string...
4
by: Neo Geshel | last post by:
Greetings I am using VB in my ASP.NET project that uses an admin web site to populate a database that provides content for a front end web site. I am looking for a way to use replace() to...
4
by: Kevin Thomas | last post by:
Hi there, If I have a string var, strFoo that contains double-quotes such that it looks like this: I "love" VB What do I pass into the "replace" method to replace the double-quotes with...
4
by: AZNewsh | last post by:
I am storing HTML in an oracle database, this is loaded from a textbox in a webpage, I convert ' to ' ' using the code below: foo.Replace("'", "''").Replace("&", "'||'&'||'") this works just...
3
by: Eric Layman | last post by:
Hi, I've saved data into the db by doing a replace() on single quote. Right now on data display on a datagrid, it shows double single quote. How do I make changes during run time of datagrid...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
23
by: dkirkdrei | last post by:
I am having a bit of trouble trying to double up on slashes in a file path. What I am trying to do is very similar to the code below: <? $var =...
6
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello, I have some XML that is returned to my application from another vendor that I cannot change before it gets to me. I can only alter it after it gets to my application. That being said, I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.