function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DharshniDharshni 

Issue with RichText field

I am using a rich-text area field in a VF page, in <inputField> tag. The space characters entered in this editor is displayed as normal ' ' character in the backend. But when I do some manipulation, for eg., replace all space with some other character, some of the space characters wouldn't change. 

 

When I used a HEX editor and encoding methods, I see that some space characters are actually present as a special character - exactly 'Å'.

 

These characters are causing troubles when I send this richtext field to a webservice,through XML. I am enclosing the data in CDATA tag, but the problem is caused by the special encoding.

 

Could you please let me know how I can replace these special space characters to normal spaces?

 

Many thanks. 

Best Answer chosen by Admin (Salesforce Developers) 
DharshniDharshni

Hi,

 

I have fixed the issue. It was a problem caused by character set compatibility. ASCII support characters till 0x7F, while UNI-code supports a larger set. &nbsp; whose code - U+00A0, is not available in ASCII. So was the problem.

 

I included the following code and it got replaced properly:

 

str = str.replaceAll('[\\u00A0]',' ');

Hoping to write a regular expression, which replaces all characters out of ASCII range. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

Try the below code snippet as reference:

str = str.replace('Å',' ').replace('\'',' ');

For the all the special character and replace it with space.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

DharshniDharshni

Hi,

 

I have fixed the issue. It was a problem caused by character set compatibility. ASCII support characters till 0x7F, while UNI-code supports a larger set. &nbsp; whose code - U+00A0, is not available in ASCII. So was the problem.

 

I included the following code and it got replaced properly:

 

str = str.replaceAll('[\\u00A0]',' ');

Hoping to write a regular expression, which replaces all characters out of ASCII range. 

This was selected as the best answer