RTF Hyperlinks with Quotes

General TRichView support forum. Please post your questions here
Post Reply
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

RTF Hyperlinks with Quotes

Post by Michel »

Hi Sergey,

I seem to have made a stunning discovery :wink:: Word 97 (and Win2k's WordPad) don't like RTF Hyperlinks with quotes.
Basically, if OnWriteHyperlink() event handler sets Target to:
filename -> all is well
"filename" -> WordPad displays <>, Word 97 displays "Error! Hyperlink reference not valid"
""filename"" -> Same
file"name -> Both Word and WordPad display "file" as the target (cut-off at the quote)

I can of course simply ensure filenames are not enclosed in quotes when exporting RTF or copying to the Clipboard, but I was wondering if you know about this issue and if there's some "correct" way to encode quotes. What if the link is not to a file but some arbitrary text that may contain embedded quotes? Not likely to happen, but still.

Thanks,

Michel
Sergey Tkachenko
Site Admin
Posts: 17283
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Double quotes are not allowed in Windows file names.
As for double quotes around the file name, I cannot reproduce the problem. Word97 iteself adds them (at least, if the file name has spaces)
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

Sergey,

That double quotes aren't allowed in filenames, I knew. I am more concerned about the following cases:
A) The user creates a link enclosed in quotes, e.g., "File space name.txt",
B) The user creates a link to something other than a simple file, which may contain quotes (I do have such "complicated" links, e.g., executable with parameters),
C) The user creates a URL link to something like groups.google.com/groups?as_q="TRichView" (and yes, as much as quotes are illegal in URLs and should be represented by %22, the above works fine in both IE and Opera).

Now, to Word 97. I just re-tested, and in my case it is removing the quotes. Steps: In Word choose Insert->Hyperlink, In the dialog box "Link to file or URL" type "abc" or "C:\Whatever Path With or Without Spaces\FileName.txt" or whatever else you like - including the surrounding quotes, hit Ok. We get the link in the document. If you place the cursor on the link and invoke the same Hyperlink dialog box, the link is no longer enclosed in quotes.
If in the examples above I use the Google URL from "case C", Word chops it off at the first quote character.
This is with Word 97 SR-1.
Or did you mean that Word 97 itself adds them in the RTF file when it saves it? That's quite true, it does, but that's not what's causing me grief...

Thanks,

Michel
Sergey Tkachenko
Site Admin
Posts: 17283
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I think you need to change quotes to %22 when saving RTF hyperlinks.
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

Yes, Sergey, you're right: %22 does the trick. Turns out that Word 2003 understands %22 as " just fine, but Word 97 doesn't (I haven't tried any in-between versions). Oh well, guess I'll have to sacrifice compatibility with the venerable 97 on this occasion...

As always - thank you for your help!

Michel
Post Reply