Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
Convert ASCII decimal to string

I have a string in representation of ASCII decimal stored in a column in my db:

[104 105]

this converts to hi.

I need to be able to convert my column into string representation.

I know I can use String.fromCharCode(num,...num+1) but it doesn't quite work for me.

I would need to parse and split my db column value [104 105] into two separate vars:

var num1 = 104;
var num2 - 105;

this doesn't work when I have a complex ASCII decimal representation.

Is there a more efficient way to do this? My input would be something like [104 105 243 0 0 255...] which is in ASCII decimal and I need to get the string representation.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to parse that string first, by removing the [] characters, splitting at spaces, and converting the array elements to numbers.

let num_string = '[104 105]';
let nums = num_string.replace(/[\[\]]/g, '').split(' ').map(Number);
let string = String.fromCharCode(...nums);
console.log(string);

about 4 years ago · Juan Pablo Isaza Report

0

You can find the codes using match with a regex, and then map and return an array of the converted codes. Just join the array into a string at the end.

function convert(str, re) {
  return str.match(/(\d+)/g).map(code => {
    return String.fromCharCode(code);
  }).join('');
}

console.log(convert('[104 105]'));
console.log(convert('[104 105 243 0 0 255]'));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!