const o = {
title: "Toto je:\\ntitle — test .. —____— –__– ’’tst’’",
note: "Toto je:\\nnote — test .. —____— –__– ’’tst’’"
}
function fix_string(str) {
let new_str = str
const replace_arr = [
['—', '—'],
['–', '–'],
['’', '’'],
['\\n', '\n'],
]
replace_arr.forEach(replace => (new_str = new_str.replaceAll(replace[0], replace[1])))
return new_str
}
function fix_obj_strings(o) {
o.title = fix_string(o.title)
o.note = fix_string(o.note)
}
// console.dir(o)
// console.log('\n')
fix_obj_strings(o)
// console.dir(o)
// console.log('\n')
console.log(o.title)
// console.log('\n')
console.log(o.note)