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

195
Visualizações
Troubles trying to use Russian strings as values in a JSON variable using Javascript in a HTML page

In order to translate some values inside a big JSON (from Italian to Russian) and split it in smaller files, I've created an offline html + Javascript page, in order to to obtain a series of JSON files in a zip (using JSZip). But the Cyrillic strings are not displayed correctly.

The page starts from a JSON stored in a variable, iterates it in order to find certain keys, then reassign the related values with others values taken from an associative array like this:

var translations = {};
translations['Retro Armadio'] = 'Задняя сторона шкафа';
translations['Stagno'] = 'Водонепроницаемый';
translations['Zoccolo'] = 'Цоколь';

The page then stringify the JSON in order to display it in a "pre" Tag and generates the zip file with the splitted JSONs using JSZip:

var zip = new JSZip();
for (const key in bigJSON){
  var currentJSON = JSON.stringify(bigJSON[key]);
  var currentFileName = key + "-ru.json";
  zip.file(currentFileName, currentJSON);
}

Unfortunately both inside the "pre" tag and inside the zip file, the Cyrillic strings are corrupted. I also tried using encodeURIComponent/decodeURIComponent, but I obtain strings like this: "Ð›Ð¸Ñ†ÐµÐ²Ð°Ñ Ñторона шкафа"

To edit the HTML page I'm using Notepad++ in UTF-8. I copy and paste the Cyrillic strings from MS Excel.

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