0

I send post request to my express server with body payload

handle: "new-text-collection-tech-gen"
raw:  "Нова коллекція"
title: "%D0%9D%D0%BE%D0%B2%D0%B0%20%D0%BA%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D1%96%D1%8F"

But i receive unexpected encoding of Cyrillic characters in body

body: {
    title: '%D0%9D%D0%BE%D0%B2%D0%B0%20%D0%BA%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D1%96%D1%8F',
    raw: 'PP>P2P0 P:P>P;P;P5P:QQQ',
    handle: 'new-text-collection-tech-gen'
}

And If I run decodeURI(title, 'utf-8') I expected to get back "Нова коллекція" but I get "PP>P2P0 P:P>P;P;P5P:QQQ"

I tried to use decodeURIComponent, tried not to set utf8 explicitly, tried to add app.use(express.json({ encoding: 'utf-8' }));

Please, help me to debug, where to look.

I use "express": "^4.18.2"

I am not sure what part of the code is relevant to provide, so just ask when having a question

Dmitry Klymenko
  • 173
  • 4
  • 11
  • 1
    You face a [mojibake](https://en.wikipedia.org/wiki/Mojibake) case (*example in Python for its universal intelligibility*): `print(b''.join([int.to_bytes( x & 0x7F, 1) for x in 'Нова коллекція'.encode( 'utf-8')]).decode( 'ascii'))` returns `PP>P2P0 P:P>P;P;P5P:QQQ` (lost the most significant bit in each byte). – JosefZ Jan 25 '23 at 13:32

0 Answers0