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

311
Views
Check if a UTF-8 character or string can be converted into Windows-1252 in Javascript?

I need to store form data sent from the browser into a database that stores text in Windows-1252. Since modern browsers will send the form data to my backend as UTF-8, I plan to validate the input both on the browser as well as in the backend to make sure I am not storing garbage into the database.

Is there a function in Javascript that checks if a UTF-8 character or string can be converted into Windows-1252 so that I can warn the user that an illegal character was detected before form submission? For example let's say I have a function is_w1252(unicodeChar) that has the following inputs/outputs:

utf8 Input | Output
----------------------------------------------------------
'a'        | true
'è'        | true (has windows-1252 equivalent: 0xE8)
'fèèbar'   | true
'👍'       | false (no windows-1252 equivalent)

Is there such a thing?

My PHP backend is much more simple; I plan to use iconv() to convert the form data into Windows-1252 before storing it into the database.

about 4 years ago · Juan Pablo Isaza
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!