Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Is there a function to use ASCII values
germobirt
Right now I'm looking for ways to replace CR/LF Chars from data.<br />
<br />
I've found on way by using a "Dynamic Text" and this expression:<br />
<span style='font-family: Courier New'>row["myField"].replace("\n","<BR>")</span><br />
<br />
But is there a way to replace chars with ASCII values e.g.<br />
<span style='font-family: Courier New'>row["myField"].replace("\n",<em class='bbc'>Asc(10)</em>)</span><br />
<br />
Is there a function to use ascii values like in other script languages?
Find more posts tagged with
Comments
johnw
You can use the UNICODE qualifiers to replace, so
row["myField"].replace("\n", '\u0010');
should work. But since you want to replace all newlines, you would probably want to do something like:
var myString = new Packages.java.lang.String(row["myField"]);
myString.replaceAll('A', '\u0067');
this way you have access to the replaceAll method.
johnw
Also, since this is Javascript, you might need to write your own function to do this using the User Script LIbrary extension point. The function would look something like:
char convertToChar(int in)
{
return (char)in;
}
since Javascript doesn't support casts.