Created
March 31, 2022 19:24
-
-
Save iamcsharper/45cb9a5ab596f00bab561655a3639ce8 to your computer and use it in GitHub Desktop.
Imitate bad encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dict = | |
"óåìøóëËÔÒÉÆÉËÁÃÉÑ ÀÖÎÙÈ ÇÕÂÅÒÎÉÊ ÄÁÓÔ ÍÏÝÎÙÊ ÔÏÌÞÏË ÐÏÄߣÍÕ ÓÅÌØÓËÏÇÏ ÈÏÚÑÊÓÔ×Á."; | |
const text = `Виды выплат компенсационного характера | |
Выплаты на детей | |
Компенсации по уходу за нетрудоспособными | |
Платежи участникам техногенных аварий | |
Выплаты обучающимся | |
Компенсации военнослужащим и членам их семей | |
Платежи переселенным вынужденно | |
Выплаты инвалидам | |
Итоги | |
Заключение`; | |
const uniqueSymbols = new Set(); | |
const symbols = text.split(""); | |
for (const symbol of symbols) { | |
uniqueSymbols.add(symbol); | |
} | |
const realDict = [...uniqueSymbols]; | |
const SYMBOL_DEFS = {}; | |
const whitelist = "0123456789().,ао-•\n; ".split(""); | |
for (let i = 0; i < realDict.length; i++) { | |
const c = realDict[i]; | |
if (whitelist.includes(c)) { | |
SYMBOL_DEFS[c] = c; | |
} else { | |
SYMBOL_DEFS[c] = dict[i % dict.length]; | |
} | |
} | |
const newText = symbols | |
.map((e) => (Math.random() > 0.5 ? SYMBOL_DEFS[e] : e)) | |
.join(""); | |
console.log(newText); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment