
Chris Sears
Top achievements
Rank 1
Chris Sears
asked on 23 Apr 2008, 07:10 PM
When the user types the space bar, RadEditor sometimes inserts a non-breaking space character ( ). This is great, but when switching to the HTML view, RadEditor displays as normal spaces. There are times when you need to differentiate between a normal and non-breaking space and that now becomes very difficult to do.
Would it be possible to add a property to enable/disable non-breaking space auto-conversion while in HTML mode? EnableHtmlNonBreakingSpaceConversion or something similar?
Would it be possible to add a property to enable/disable non-breaking space auto-conversion while in HTML mode? EnableHtmlNonBreakingSpaceConversion or something similar?
11 Answers, 1 is accepted
0
Hello Chris,
The addition of the when pressing the space button more than once is a browser behavior. This is the entity that the browser uses to insert long intervals between the words in the web editors.
If you want to strip automatically and programmatically the addition of   entities then you can implement a content filter that will remove these entities when switching to Html mode or submitting the content. Here is a basic example:
<script type="text/javascript">
function RadEditorCustomFilter()
{
this.GetHtmlContent = function (content)
{
re = / /gi //search for entities in the content
newContent = content.replace(re, ""); //and replace them
return newContent;
};
}
/* Use the editor onload function to register the filter with the FiltersManager */
function onClientLoad (editor)
{
var customFilter = new RadEditorCustomFilter();
editor.FiltersManager.Add(customFilter);
}
</script>
<radE:RadEditor id="RadEditor1" OnClientLoad="onClientLoad" Runat="server"></radE:RadEditor>
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The addition of the when pressing the space button more than once is a browser behavior. This is the entity that the browser uses to insert long intervals between the words in the web editors.
If you want to strip automatically and programmatically the addition of   entities then you can implement a content filter that will remove these entities when switching to Html mode or submitting the content. Here is a basic example:
<script type="text/javascript">
function RadEditorCustomFilter()
{
this.GetHtmlContent = function (content)
{
re = / /gi //search for entities in the content
newContent = content.replace(re, ""); //and replace them
return newContent;
};
}
/* Use the editor onload function to register the filter with the FiltersManager */
function onClientLoad (editor)
{
var customFilter = new RadEditorCustomFilter();
editor.FiltersManager.Add(customFilter);
}
</script>
<radE:RadEditor id="RadEditor1" OnClientLoad="onClientLoad" Runat="server"></radE:RadEditor>
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Chris Sears
Top achievements
Rank 1
answered on 24 Apr 2008, 04:44 PM
Hey Rumen,
Thanks for the quick reply. I actually don't want to strip the characters. I just want to be able to see them when in HTML mode. In my opinion, HTML mode should display EXACTLY what is being stored. This actually goes beyond and includes all HTML special characters.
If I look in my database and see that the text is saved as "<p>Here is s;some s;text</p>", I want this to be what I see in HTML mode within RadEditor. At the moment, I see "This is some text" because the characters are being displayed as spaces instead of being displayed literally.
So I guess the question is: why is RadEditor displaying special character codes as glyphs in HTML mode? Can this be disabled so we can see the actual text that will be stored in our database and output in our pages?
Thanks for the quick reply. I actually don't want to strip the characters. I just want to be able to see them when in HTML mode. In my opinion, HTML mode should display EXACTLY what is being stored. This actually goes beyond and includes all HTML special characters.
If I look in my database and see that the text is saved as "<p>Here is s;some s;text</p>", I want this to be what I see in HTML mode within RadEditor. At the moment, I see "This is some text" because the characters are being displayed as spaces instead of being displayed literally.
So I guess the question is: why is RadEditor displaying special character codes as glyphs in HTML mode? Can this be disabled so we can see the actual text that will be stored in our database and output in our pages?
0
Hi Chris,
The content displayed in HTML mode of RadEditor is identical to this one which is submitted to the server. In both cases the content is retrieved from Design mode trough the editor.get_html(true) method.
If the content on the server looks different from this in HTML mode then this issue is not due to RadEditor.
For example it could be a browser specific issue - the empty spaced are saved by some browsers like and by others like other spaces. The problem could appear if you save the content from some browser and load it in another one.
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The content displayed in HTML mode of RadEditor is identical to this one which is submitted to the server. In both cases the content is retrieved from Design mode trough the editor.get_html(true) method.
If the content on the server looks different from this in HTML mode then this issue is not due to RadEditor.
For example it could be a browser specific issue - the empty spaced are saved by some browsers like and by others like other spaces. The problem could appear if you save the content from some browser and load it in another one.
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

leapopotomus
Top achievements
Rank 1
answered on 30 May 2008, 12:47 AM
I had a different problem where i would get question mark characters (?) in place of where there were spaces after saving the html. It was caused because i was saving the html as ASCII instead of UTF-8.
My problem and your problem are probably both caused when using the Editor in IE.
IE will store non breaking spaces as unicode character U+C2A0 and not as like FF does.
In the case where the HTML is displayed in a different encoding to UTF-8 this can lead to strange characters appearing like  (or in my case ?).
I solved my problem by saving the html as UTF-8 but I guess the solution to make appear instead of U+C2A0 would be to apply a filter that converts U+C2A0 to
My problem and your problem are probably both caused when using the Editor in IE.
IE will store non breaking spaces as unicode character U+C2A0 and not as like FF does.
In the case where the HTML is displayed in a different encoding to UTF-8 this can lead to strange characters appearing like  (or in my case ?).
I solved my problem by saving the html as UTF-8 but I guess the solution to make appear instead of U+C2A0 would be to apply a filter that converts U+C2A0 to
0

Jeff
Top achievements
Rank 1
answered on 09 Aug 2009, 07:51 PM
Hello,
I am also having trouble persisting the entity in IE8. I'm using 2009.2.701.35.
In particular, I use the following to break up sections in long documents:
In Design mode of the editor, you can get the <p> </p> by hitting enter to create a blank line. When you first switch to HTML mode, the is there. Switch back to Design then back to HTML and the is replaced by an actual space (ASCII 32).
This seems like a bug to me. Even if it isn't, I still would like to come up with a workaround for this.
Like Chris, it is extremely important for me to preserve these entities.
This problem is reproducible without round trips to the server and without cutting and pasting text from anywhere. The Editor creates the and it takes it away.
Any ideas?
Thanks,
Jeff
I am also having trouble persisting the entity in IE8. I'm using 2009.2.701.35.
In particular, I use the following to break up sections in long documents:
<p>...conclusion of last section.<p> |
<p> </p> |
<h2>Next Section</h2> |
In Design mode of the editor, you can get the <p> </p> by hitting enter to create a blank line. When you first switch to HTML mode, the is there. Switch back to Design then back to HTML and the is replaced by an actual space (ASCII 32).
This seems like a bug to me. Even if it isn't, I still would like to come up with a workaround for this.
Like Chris, it is extremely important for me to preserve these entities.
This problem is reproducible without round trips to the server and without cutting and pasting text from anywhere. The Editor creates the and it takes it away.
Any ideas?
Thanks,
Jeff
0
Hi Jeff,
Please, try the following custom content filter that should replace the empty space symbol with inside the <p> <p> tags:
Feel free to enhance the filter to fit your scenario.
All the best,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please, try the following custom content filter that should replace the empty space symbol with inside the <p> <p> tags:
<telerik:radeditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad"> |
<Content> |
<p>...conclusion of last section.</p> |
<p> </p> |
<h2>Next Section</h2> |
</Content> |
</telerik:radeditor> |
<script type="text/javascript"> |
function OnClientLoad(editor, args) |
{ |
editor.get_filtersManager().add(new RadEditorCustomFilter()); |
} |
RadEditorCustomFilter = function() |
{ |
RadEditorCustomFilter.initializeBase(this); |
this.set_isDom(false); |
this.set_enabled(true); |
this.set_name("RadEditor filter"); |
this.set_description("RadEditor filter description"); |
} |
RadEditorCustomFilter.prototype = |
{ |
getHtmlContent : function(content) |
{ |
//Make changes to the content and return it |
content = content.replace(/ /gi, " ") |
return content; |
} |
} |
RadEditorCustomFilter.registerClass('RadEditorCustomFilter', Telerik.Web.UI.Editor.Filter); |
</script> |
Feel free to enhance the filter to fit your scenario.
All the best,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Jeff
Top achievements
Rank 1
answered on 12 Aug 2009, 01:02 AM
Hi Rumen,
It was a good attempt but it doesn't work.
In IE, it does nothing. Closer inspection reveals that these aren't space characters (ASCII code 32). I'm not sure what they are. I just see a square box (unprintable character) when I do a Quick Watch in VS2008.
Can you try and reproduce this problem. I'm even more convinced that this is a bug.
Here are the steps (IE 8 only):
Beyond that, the filter you provided is too aggressive- every space character is turned into an . I'm really looking for this in two cases:
Thanks for your help.
Jeff
It was a good attempt but it doesn't work.
In IE, it does nothing. Closer inspection reveals that these aren't space characters (ASCII code 32). I'm not sure what they are. I just see a square box (unprintable character) when I do a Quick Watch in VS2008.
Can you try and reproduce this problem. I'm even more convinced that this is a bug.
Here are the steps (IE 8 only):
- Type a paragraph of text
- Create a blank line
- Create another line of text
- Switch to HTML mode. Everything looks great: The blank line reads <p> </p>
- Switch to Design mode
- Switch to HTML mode: The blank line is now <p>[funny unprintable character]</p>
Beyond that, the filter you provided is too aggressive- every space character is turned into an . I'm really looking for this in two cases:
- On a blank line
- When there is more than one space character in a row, the extra spaces should be .
Thanks for your help.
Jeff
0
Hello Jeff,
The is not replaced by space (ASCII 32) but by a non-breaking space. Both spaces look identically, but actually this is not a normal space.
My suggestion is to replace the normal spaces with non breaking spaces on the server using a simple Stripng.Replace method, e.g.
TextBox1.Text = RadEditor1.Content.Replace("\xA0", " ").Replace("\x20"," ");
You can find more information here.
All the best,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The is not replaced by space (ASCII 32) but by a non-breaking space. Both spaces look identically, but actually this is not a normal space.
My suggestion is to replace the normal spaces with non breaking spaces on the server using a simple Stripng.Replace method, e.g.
TextBox1.Text = RadEditor1.Content.Replace("\xA0", " ").Replace("\x20"," ");
You can find more information here.
All the best,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Jeff
Top achievements
Rank 1
answered on 17 Aug 2009, 11:47 PM
That's absolutely what I'm seeing: it's a hex A0 Unicode character.
While I would still prefer to have the character entity, the A0 character does have the same effect as the in all of the browsers I've tested: IE, Firefox and WebKit.
The <p>0xA0</p> does result in a blank line, which is what I'm looking for.
I hope a future version of the controls will catch the A0 character and convert it to . But I can live with the current behavior.
Thanks again.
Jeff
While I would still prefer to have the character entity, the A0 character does have the same effect as the in all of the browsers I've tested: IE, Firefox and WebKit.
The <p>0xA0</p> does result in a blank line, which is what I'm looking for.
I hope a future version of the controls will catch the A0 character and convert it to . But I can live with the current behavior.
Thanks again.
Jeff
0

Jeff
Top achievements
Rank 1
answered on 18 Aug 2009, 07:19 PM
For anyone else who is as picky as me about proper HTML, I came up with a RegEx to replace the non-breaking space Unicode character (hex A0) with the entity.
The RegEx looks like this:
content = content.replace(/\xA0/gi, " ");
Here's Rumen's filter example with the new RegEx:
I hope that helps someone out there!
The RegEx looks like this:
content = content.replace(/\xA0/gi, " ");
Here's Rumen's filter example with the new RegEx:
<telerik:radeditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad"> |
<Content> |
<p>...conclusion of last section.</p> |
<p> </p> |
<h2>Next Section</h2> |
</Content> |
</telerik:radeditor> |
<script type="text/javascript"> |
function OnClientLoad(editor, args) |
{ |
editor.get_filtersManager().add(new RadEditorCustomFilter()); |
} |
RadEditorCustomFilter = function() |
{ |
RadEditorCustomFilter.initializeBase(this); |
this.set_isDom(false); |
this.set_enabled(true); |
this.set_name("RadEditor filter"); |
this.set_description("RadEditor filter description"); |
} |
RadEditorCustomFilter.prototype = |
{ |
getHtmlContent : function(content) |
{ |
//Make changes to the content and return it |
content = content.replace(/\xA0/gi, " "); |
return content; |
} |
} |
RadEditorCustomFilter.registerClass('RadEditorCustomFilter', Telerik.Web.UI.Editor.Filter); |
</script> |
I hope that helps someone out there!
0

D Strube
Top achievements
Rank 1
answered on 23 Dec 2009, 02:27 PM
Dear Rumen,
This is exactly what I was looking for. Thank you!
This is exactly what I was looking for. Thank you!