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

125
Visualizações
Current state of the art for UTF-8 handling in a browser making an external post

I have an application with a browser page that allows upload of CSV to Google Drive via V2 of the api. It is only handling ASCII (I get "failed to execute btoa / string to be encoded contains characters outside the Latin1 range").

I've updated my code so that the content-type is now "text/csv;charset=UTF-8;". I am still using content-transfer-encoding of base64.

In multiple places on the web, I found recommendations of using btoa(unescape(encodeURIComponent(data))). Previously, the code was only doing btoa(data). It seems to work, though I have not tested it exhaustively.

I understand that unescape is considered in a precarious light relative to ECMA-262. Here are the questions:

  • a) does the above work for all of UTF-8 (including 4-byte chars)?
  • b) if not, will it just fail to encode properly, or will I get a browser error?
  • c) are there any other risks of using this approach (even if it handles 4-byte chars)?
  • d) is there a better / newer way of doing this? I probably have the luxury of not supporting older browsers.
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