- 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:31 AM
Hi Vishal and Sunil,
how can we exclude the spaces and dash(-) from the string, it is calculating ASCII for spaces and dash as well.
could you please help me with that.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 03:53 AM
str = str.replace(/\s/g, ""); //removes all spaces
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 04:13 AM
Thank you Sunil. it worked.