0

I have a list in which one column is of type Rich text box. I am using a console application which reads this list's item and replace a substring for example RichTextColumn contains value [subtext] then

string mytext=item["RichTextColumn"].toString();
mytext=mytext.Replace("[subtext]","******");

The above code work fine , but when Rich Text column has { or } then the code fails for example if RichTextColumn contains value {subtext} then below can't find it

mytext=mytext.Replace("{subtext}","--------");

On debugging I found mytext contains ANSI code for curly braces(&#123) instead of {

Please help me out me to resolve this issue.

1 Answer 1

1

SharePoint stores some of the Rich Text characters in ANSI format

enter image description here

You can decode the string before applying the Replace function as below

mytext = System.Web.HttpUtility.HtmlDecode(mytext);
mytext=mytext.Replace("{subtext}","--------");
3
  • Do you have a source for that image of the table? If so, please share it in your post Commented Nov 9, 2014 at 18:40
  • @RobertLindgren I have added the link to image. Commented Nov 9, 2014 at 18:49
  • Great, thanks! It's allways nice to give credit to creators Commented Nov 9, 2014 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.