- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 02:13 AM
Hello,
We have requirement to convert string to ASCII values.
for example: "hello " is the string which needs to be converted to ASCII value 72,69,76,76,79
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 02:22 AM
var string = "Some string";
for (var i = 0; i < string.length; i++) {
console.log(string.charCodeAt(i));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 02:19 AM
you can make use of charCodeAt
var str = "hello servicenow";
str.charCodeAt(0); //give ASCI of character at index 0.
You can run either run a loop and capture for all characters in string.
Cheers,
Sunil B N
P.S: If this is useful, please mark this as an answer/helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 02:22 AM
var string = "Some string";
for (var i = 0; i < string.length; i++) {
console.log(string.charCodeAt(i));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 08:23 AM
HI Vishal and Sunil,
How to remove "" from a string in a business rule as this is called in a rest message and it is giving incorrect JSON payload.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 02:27 AM
Thank you so much Sunil and Vishal.
Both answers are correct.