Skip to content

Instantly share code, notes, and snippets.

@abdullahoguk
Created October 15, 2021 16:30
Show Gist options
  • Save abdullahoguk/a047f3abeadf768a5c52a044628dcb05 to your computer and use it in GitHub Desktop.
Save abdullahoguk/a047f3abeadf768a5c52a044628dcb05 to your computer and use it in GitHub Desktop.
UTF-8 Display to Text (Turkish) with multiple replace in JavaScript
/*bozuk türkçe karakter düzeltme*/
function fixTrChars(str) {
var karakterler = [{'ı': 'ı'}, {'ç': 'ç'}, {'ÅŸ': 'ş'}, {'ö': 'ö'}, {'ü': 'ü'}, {'ÄŸ': 'ğ'}, { 'Ä°': 'İ'}, { 'Ç': 'Ç'}, { 'ÅŸ': 'Ş'},{'Ö':'Ö'}, {'Ãœ': 'Ü'}, {'ÄŸ': 'Ğ'}];
return karakterler.reduce(function (accum, t) {
return accum.replace(new RegExp(Object.keys(t)[0], 'g'), t[Object.keys(t)[0]]);
}, str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment