Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

313
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda