Apostrophe Replacement with InStr

bottom line fellas,
is the best way to handle this to turn off smart quotes ?
do i turn off smart quote for just the control(s) in question.?

I think you have a few options

  1. turn auto curly quotes off (and it varies on how you do it for a text are a vs text field - such fun)
  2. allow then & deal with them by replacing them
    they’re easy enough to find & replace with instr and replaceall
  3. update your regex to also find those items (which you can I just dont know the specifics - where’s @Kem Tekinay when you need him)

I haven’t looked, but you might try something like this instead:

https://forum.xojo.com/37359-encoding-html-entities/0#p305850

i cannot use the // Turn OFF Smart Quotes
as it renders my app useless, i get delays in processing and i get exceptions

KEM,

McGrath says his routine is a modual and a class, and then he gives a download to a .rbp file.
how might i include this class or modual into XoJo?

You need to fix the exceptions anyways because your customers might have turned off smart quotes.

Use copy and paste to get a module/class into your project.

I added the McGrath Method/Class, my app compiled
the McGrath Routines do not work with quotes or single quote as far as i know smart of otherwise.

i cannot use the turn off smart quotes unless i can find a way to it without interfering with my app running.

i found that text fields work and find and substitute quotes. if they quotes are typed in by hand or loaded from a file or database.

Textarea does not work. typed by hand or loaded from a file or database.
I even tried copying a textarea to textfield then doing the ReplaceAll or my CmpReplace ( nope does not work either )

i am at a loss

[quote=361279:@David Cullins]I added the McGrath Method/Class, my app compiled
the McGrath Routines do not work with quotes or single quote as far as i know smart of otherwise.

i cannot use the turn off smart quotes unless i can find a way to it without interfering with my app running.

i found that text fields work and find and substitute quotes. if they quotes are typed in by hand or loaded from a file or database.

Textarea does not work. typed by hand or loaded from a file or database.
I even tried copying a textarea to textfield then doing the ReplaceAll or my CmpReplace ( nope does not work either )

i am at a loss[/quote]
Do us a favor. Take one of these strings and encode it in hex or base64. Do this in your code. The goal is to prevent any kind of text replacements. We need to see the true bytes that your code sees. That’s what the encoding is for.

Post the result here.

ok working on it.

45617379206F6E20746865206579657320666F72207375726521205468657365207377616E6B79206461726B20626C75656973682073756E676C61737365732066656174757265206F76616C206C656E732C206D6574616C206672616D657320666F72206120636C617373696331393730E28099732070696563652079657420636F6E74656D706F72617279206C6F6F6B2E0A0A3C623E466561747572653C2F623E0A4C656E733A204F76616C0A4672616D65733A204D6574616C202873696C766572290A44696D656E73696F6E3A2035696E2077696465202A20312E35696E2074616C6C20202A202034696E2065796520746F206561722E0A4F766572616C6C2073697A653A20736D616C6C0A496E636C756465733A204D6963726F666962657220506F756368

http://unicode.org/cldr/utility/character.jsp?a=2019

What do you want to do with it, read it?

Ensure its in UTF8 then use this to replace it:

  ReplaceAll(Text.FromUnicodeCodepoint(&h2019), "*")

https://www.dropbox.com/s/kyc2uujdnxz62tq/TestU2019.zip?dl=1

To get the character you have in a Listbox Row:

a. add a TextField at the window’s bottom,
b. in Listbox1.Change (Event), put code to copy the selected Row into the TextField,
c. Copy the character you want to deal with

and paste it in your code.

No need to use a magnify glass to try to read what the character can be.

Just for the next time someone have a trouble.

[quote=361087:@David Cullins]Dave

I am sure the ReplaceAll will work but the problem is the “if” testing to see if the quote are there fails with my Cmp Routine and Instr[/quote]

You don’t need to test. If the curly quotes are there they will be replaced, if they are not there, nothing will happen.

I cannot help but to feel pain for you, seeing you struggling for a month and a half with a problem that a very simple series of replacements would have solved.

Note that you don’t need convoluted methods to find out the code point of the curly quotes. Just select them and copy them into your code. Like so :

ListBox1.CellText(0,0) = ReplaceAll(ListBox1.CellText(0,0), "’","'") // Right single quotation mark to single quote.

Note that you perform several replacements at the same time like so (here left and right single quotation mark to single quote) :

ListBox1.CellText(0,0) = ReplaceAll(ReplaceAll(ListBox1.CellText(0,0), "’","'"),"‘","'" )

Ouch. Seems the forum performs it’s own replacements. Anyway, that is the principle. Copy and paste between the first double quotes after the string.

Within the hex string you posted, I found one curly single quote (&u2019) in “classic1970’s”.

ReplaceAll(&u2019, “*”)

Hi Norm

ReplaceAll(&u2019, “*”) for single quotes works !

what is the replaceAll for double Quotes ?

Kem and Michael
I am trying to substitute curly single quotes and curly double quotes for
HTML equivalent ' and " respectively.

my apple keyboard produces curly single and double quotes when typed.

There are several unicode characters that might be construed as “curly quotes” (single or double)

&u2018 http://unicode.org/cldr/utility/character.jsp?a=2018
&u2019 http://unicode.org/cldr/utility/character.jsp?a=2019
&u201C http://unicode.org/cldr/utility/character.jsp?a=201C
&u201D http://unicode.org/cldr/utility/character.jsp?a=201D

In Xojo you can use the unicode code point # like I gave you earlier to replace
So you can replace these 4 with much the same call to replaceAll

[quote=362789:@David Cullins]Kem and Michael
I am trying to substitute curly single quotes and curly double quotes for
HTML equivalent ' and " respectively.

my apple keyboard produces curly single and double quotes when typed.[/quote]
You can turn this off
System Preferences > Keyboard > Text
Turn off use smart quotes & dashes