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

[Solved] Mystery 'A' bug in saved template file - take 3

2 Answers 79 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Matthew Bishop
Top achievements
Rank 1
Matthew Bishop asked on 09 Apr 2009, 07:22 AM

I came across an interesting bug that I thought I would share with everyone just in case it is happening to them as well.

When you have saved a file from the editor, if you have a tag, a space and then some text (example below), when saved the 'Â' character appears. This seems to be because a   is missing and is rather replaced with the character code 160.


<td> Some text </td> 
 
shows as  
 
 Some text 


When you view the saved file in notepad/ word pad/ visual studio etc. you do not see the character. If you view it in a hex editor, you do.
A problem only arises if you open the saved HTML file, manipulate it and then resave it because then the character code is picked up and acted on (rendered).

Once I managed to track down the problem, the fix was really quite simple, simply:

1.     Encode the text to HTML
2.     Replace the offending character with a nbsp;
3.     Decode from HTML ready for saving or more manipulation.

string contentData = Server.HtmlEncode(this._RadEditor.Content);    
contentDatacontentDatacontentData = contentData.Replace("&#160;", "&amp;nbsp;");    
contentData = Server.HtmlDecode(contentData);   
 


I must stress that this bug only appears after you try and manipulate the document by loading it, manipulating it and resaving it (but it did happen on every machine that we tested it on). If you are viewing your saved documents straight off then this should not be a problem for you.

2 Answers, 1 is accepted

Sort by
0
Adrian
Top achievements
Rank 1
answered on 09 Jun 2009, 10:46 AM
Hi,

I have also experienced this bug and have added the following line of code when I read the content of the telerik editor.

sContent = sContent.Replace(Chr(160),

"&nbsp;")

 


This does the trick, I presume this has been introduced recently as we have not seen this until our most recent release.

I am using 2009.1.402.35

Regards Adrian
0
Tervel
Telerik team
answered on 11 Jun 2009, 07:36 AM
Hello Adrian,

The #160 character (or 0xA0 in Hex) is exactly the non-breaking space. In HTML this character is  represented as &nbsp;

What happens in your case is that you open the HTML file with one encoding but save it in another (e.g. Unicode and ASCII). Make sure that you save the file without changing the encoding and you should not encounter the problem.

Best wishes,
Tervel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Matthew Bishop
Top achievements
Rank 1
Answers by
Adrian
Top achievements
Rank 1
Tervel
Telerik team
Share this question
or