This is a migrated thread and some comments may be shown as answers.

Special characters coming through in Paste from Word, even with MSWordRemoveAll

5 Answers 508 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Aaron Clausen
Top achievements
Rank 1
Aaron Clausen asked on 25 Jul 2008, 06:36 AM
Hi guys,

I am using an ASP.Net AJAX RADEditor in an ASP.Net 2.0 application. We have just upgraded to this new Editor. Formerely, our application used the traditional RADEditor which had XML config files etc and ran on ASP.Net 1.1.

We seem to have migrated everything successfully and the editor is working pretty well. But we are unfortunately experiencing some problems pasting content directly from word - these didn't happen with the old version.

For example: The apostrophe's that MSWord uses are a special character that differs from a standard apostrophe in XHTML.

Here is some text I pasted from Word into the RADEditor:
" telcos’"

But I end up seeing funny characters like this inside the RADEditor:
telcos’

Because the apostrophe that Word uses is a weird, non-standard one..

My code for the editor is:

<telerik:RadEditor ID="RadEditor" Runat="server" Width="500px" Skin="Default"
    ToolProviderID="" StripFormattingOptions="MSWordRemoveAll"><Content>
</Content>
</telerik:RadEditor>

If I paste a couple of pages from a Word Document, the result is terrible, it is full of lots of other funny characters and sometimes Greek for bulleted text.

NOTE: It always looks perfect in the RADEditor straight after the paste. Its only after I save the RADEditor and then load it back up later inside the RADEditor that I see the funny characters all through the content. My thoughts are that these funny apostrophes should be replaced with standard apostrophes automatically during the paste, and this kind of thing isn't happening properly. RADEditor displays the apostrophes correctly straight after the paste, but after a fresh load populating the content at runtime, it realises they are funny characters and displays them accordingly.

My RADEditor saves inline, because its part of a custom CMS system. The inline-saving was done using a tutorial document on this web site which worked great.

Any other hints or tips or something that I need to configure? My staff are getting frustrated because they can't paste from word without seeing funny characters.

Is there a need for me to code my own custom replace filter, this would take some time, I assumed the MSWordRemoveAll should do all this for me.

I have taken 4 screenshots of what happens if they are helpful.

Thanks heaps for your help

Aaron.


5 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 28 Jul 2008, 06:26 AM
Hi Aaron,

You can see the following help article on the subject which provides guidance how to fix the Greek character issue in RadEditor Classic: Appearance of Greek symbols on pasting from Word.
The solution for the new RadEditor for ASP.NET AJAX is to use the following code:

<telerik:radeditor runat="server" ID="RadEditor1"></telerik:radeditor>
<script type="text/javascript">
Telerik.Web.UI.Editor.Utils._oldstripWordFormatting = Telerik.Web.UI.Editor.Utils.stripWordFormatting;
Telerik.Web.UI.Editor.Utils.stripWordFormatting = function(html, clearValue)
{
   var result = Telerik.Web.UI.Editor.Utils._oldstripWordFormatting(html, clearValue);
   var fontCleaner = /(\<span style=\"[a-z\-\:\s0-9\;]*)(font-family\s*\:\s*Symbol)/ig;
   var newContent = result.replace(fontCleaner,"$1");
   return newContent;
}
</script>

Please, note that the Greek chars issue is due to that in the pasted content from MS Word the bullets are represented as point characters wrapped inside FONT tags with font name Symbol instead of <OL> and <LI>
HTML tags. We need to strip the Symbol font because in other case the content will be displayed always with Greek chars.

In regards to the encoding problem: You should set you page and request encoding to UTF-8:

<meta http-equiv="content-type" content="text/html; charset=utf-8">

Save the file with the editor with Unicode (UTF-8 with signature) encoding.

Put the following globalization tag in the <system.web> tag in the web.config file.

<globalization fileEncoding="UTF-8"/>


If you still experience any problems, please open a support ticket and attach a sample running project along with sample word content, steps to reproduce the issue and screenshots.

Kind regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Aaron Clausen
Top achievements
Rank 1
answered on 29 Jul 2008, 11:14 AM
Hi Rumen,

This fixed the problem perfectly! :) Thanks for your help so much.

Question: Can this additional code be included in the next release of the RADEditor so that it works automatically without developers needing to add this extra script right below the RADEditor?

Now I have no more Greek or funny symbols!!!

Regards

Aaron.
0
Rumen
Telerik team
answered on 30 Jul 2008, 08:18 AM
Hi Aaron,

Of course, I logged the problem in our bug tracking system and we will include the code in the editor.

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Aaron Clausen
Top achievements
Rank 1
answered on 30 Jul 2008, 10:35 PM
Hi Rumen,

Some not so good news. It looks to have fixed it only in Firefox. In Firefox, its working PERFECTLY. This is the browser that I use for development.

In IE, when the page first loads, a Javascript Error dialogue pops up saying:
A Runtime Error has occured.
Do you wish to Debug?

Line: 135
Error: 'Telerik' is undefined

I click No, then get another identical error, except this time its Line: 163, then a third one comes up for Line: 193.

I reloaded and decided to Debug in VS. The first error is coming from this line:

<script type="text/javascript">
Telerik.Web.UI.Editor.Utils._oldstripWordFormatting = Telerik.Web.UI.Editor.Utils.stripWordFormatting;

For some reason IE's Javascript doesn't understand what "Telerik" is and throw the error. Yet its fine in Firefox!!!

If I keep clicking "No" and ignoring these errors, then when I have the editor loaded up and I decide to paste something into the RADEditor from MSWord, a very nasty error happens:

"Microsoft JScript runtime error: Out of memory"

This then breaks the JS debugger inside VS on the line of code:
var result = Telerik.Web.UI.Editor.Utils._oldstripWordFormatting(html, clearValue);



I have saved the temporary file rendered at runtime by IE that is displayed when debugging within VS. Because this contains the fully rendered code and is what it refers to when it says "Line 135" etc.

Any idea why it works in Firefox but now IE ? :(

Thanks

Aaron.
0
Aaron Clausen
Top achievements
Rank 1
answered on 01 Aug 2008, 01:41 AM
Hi Rumen,

I fixed this error!

On my particular web page, I had 3 RADEditors at the same time, in different parts of the page, because its for inline editing inside a CMS system. But only one RADEditor can be visible at a time. My RADEditor is bundled inside my own user control, which also included the extra script that you gave me the other day.

Anyway, I think the problem was because the script was in the wrong section of the html document OR that it was repeated 3 times. Most likely that it was in the wrong section of the document, because I received the error 3 times, indicating that it happened for each and every instance of the script, not just the 2nd and 3rd instances.

So I moved your bugfix script out of my user control and into the HEAD of the HTML document only once. So this script is not repeated now.

This now works fine in IE, no errors whatsoever. But always worked in Firefox and still does.

Regards

Aaron.
Tags
Editor
Asked by
Aaron Clausen
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Aaron Clausen
Top achievements
Rank 1
Share this question
or