Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda