+ Start a Discussion
mariappangomathirajmariappangomathiraj 

How to add '|' symbol to string in apex controller?

string s = '|'+'Test';
system.debug(Logginglevel.ERROR,'::::s3:::::::'+s);

 

Output:

::::s3:::::::|Test

 

Expected Output:

::::s3:::::::    |Test

 Is it possible to get the above output?

Suresh RaghuramSuresh Raghuram

I just executed in the developer console. It is comming so it should also come in the apex controller.

 

AshlekhAshlekh

Hi,

 

I also executed in developer console and it is showing expected output.  but when  see in debug console  than it show me &#123.

 

how......

 

 

@anilbathula@@anilbathula@

Hi

The way ur using is correct when using system.debug to see the output it showing different but if ur storing this value in any field it showing the correct value.i tried this string s = '|'+'Test'; in a trigger it worked perfectly.

Instead of using system.debug().just try system.assert to compare the value.

sandeep@Salesforcesandeep@Salesforce

try 

 

'\|'

Thomas DvornikThomas Dvornik

It's not in the actual log since we use that as a parse token, but we render it in the log view as '|'. The raw log will show the encode value.

David Roberts 4David Roberts 4
Works for "new line" (carriage return + line feed) concatenations, too:
                    c.Description  = "First line";
                    for (Integer k=1; k<nFields; k++)
                    {
                        c.Description = c.Description + '\n' + newlines[k];
                    }