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
greg-ugreg-u 

carriage return (#xA) handling in sforce

Hi ,

has anyone experience with character rererences, i.e. #xA in the multiline address field in Account/Contact object?

Do the query and create/update methods correctly handle this character references, as specified in XML 1.0 Spec.?

Thanks
Gregor

Mike LeachMike Leach

Textarea line breaks come across the wire as newline carriage returns. You'll need to parse and HTML Encode them.

C# Example:

Code:

public string ParseText(string text)
        {            
            StringBuilder sb = new StringBuilder(text);
            
            sb.Replace("  ", "  ");
            sb.Replace("<", "&lt;");
            sb.Replace(">", "&gt;");
            sb.Replace("\"", "&quot;");
            
            StringReader sr = new StringReader(sb.ToString());
            StringWriter sw = new StringWriter();
            
            while (sr.Peek() > -1)
            {
                string temp = sr.ReadLine();
                sw.Write(temp + "<br>");
            }
            
            return sw.GetStringBuilder().ToString();
        }


 

greg-ugreg-u
Thanks Mike,

your hints helped me out!

Regards, Gregor