473,549 Members | 2,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 20895
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
internationaliz ation 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 RightSingleQuot e As Char = ChrW(&H2019)
Const LeftDoubleQuote As Char = ChrW(&H201C)
Const RightDoubleQuot e As Char = ChrW(&H201D)

' other typographic quote characters (international)
' Note: HP48 uses these for delimiters
Const LeftPointingDou bleAngleQuote As Char = ChrW(&HAB)
Const RightPointingDo ubleAngleQuote As Char = ChrW(&HBB)

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

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

text = text.Replace(Le ftDoubleQuote, Apostrophe)
text = text.Replace(Ri ghtDoubleQuote, Apostrophe)

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

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*******@disc ussions.microso ft.com> wrote in message
news:75******** *************** ***********@mic rosoft.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*******@disc ussions.microso ft.com> wrote in message
news:75******** *************** ***********@mic rosoft.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*******@disc ussions.microso ft.com> wrote in message
news:71******** *************** ***********@mic rosoft.com...
Thank you very much. It worked :)

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

Jay

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:eS******** ******@TK2MSFTN GP10.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
14418
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 sequence in the XML document. am not able to locate such elements using an XPath expression. I trie the following: //*
6
22109
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 again...Converts my '' to ""...strange, but ok. String strXML = doc.OuterXml; //trying to convert back the single quotes to double quotes
4
3118
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 replace multiple entries of an object within a string. That is, if a user hit twice to create one new line, but just once to create another, I want...
4
24345
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 something else? strFoo = strFoo.replace(???,"&quot;")
4
2204
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 fine, then when I retrieve the text from the database and display it in a webpage, I convert it back using: objdr.Item("foo").Replace("''",...
3
2728
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 so that the double single quote will be replaced as single quote? Pls advise.
15
4452
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 enased whitespace (to my best memory) AT other times I get an undefined index notice as below: Notice: Undefined index: last_reminder_id in...
23
13426
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 = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf"; $new = preg_replace("\\", "\\\", "$var"); ?> Code above produces the following error:
6
3083
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 am having a problem loading the XML correctly into my app. Here is the code: ==================================== Dim sPaymentXML as String
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.