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

349
Visualizações
How to decode specific characters (unicode) in Google Sheets

I have a Sheets that contains text as défi (défi) or Österreich (Östereeich).

I can decode the first by this script, on the other hand I am not able to do the second (I mean the code takes 3 bytes)

Thanks for any help!

function decode(txt){
  var texte = []
  for (i=0;i<txt.length;i++){
    var n = txt.substring(i,i+1).charCodeAt()
    if (n>127){
      if ((n & 32) > 0){
        //texte.push(decode_utf8(txt.substring(i,i+3))) ??
        i+=2
      }
      else{
        texte.push(decode_utf8(txt.substring(i,i+2)))
        i++
      }
    }
    else{
      texte.push(txt.substring(i,i+1))
    }
  }
  return (texte.join(''))
}
function decode_utf8(s) {
  return decodeURIComponent(escape(s));
}
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Here is a solution ... based on github

function utf8decode(utftext) {
  var string = "";
  var i = 0;
  var c = c1 = c2 = 0;
  while ( i < utftext.length ) {
    c = utftext.charCodeAt(i);
    if (c < 128) {
      string += String.fromCharCode(c);
      i++;
    }
    else if((c > 191) && (c < 224)) {
      c2 = utftext.charCodeAt(i+1);
      string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
      i += 2;
    }
    else {
      c2 = utftext.charCodeAt(i+1);
      c3 = utftext.charCodeAt(i+2);
      string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
      i += 3;
    }
  }
  return string;
}
about 4 years ago · Santiago Gelvez Relatório
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