Hi Sergey,
I seem to have made a stunning discovery : 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
RTF Hyperlinks with Quotes
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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
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
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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
As always - thank you for your help!
Michel