Save Accents in MySQL Database

Personally I solved the same issue by adding after the MySQL connection code: mysql_set_charset(“utf8”); or for mysqli: mysqli_set_charset($conn, “utf8”); or the mysqli OOP equivalent: $conn->set_charset(“utf8”); And sometimes you’ll have to define the main php charset by adding this code: mb_internal_encoding(‘UTF-8’); On the client HTML side you have to add the following header data : <meta … Read more

Replacing diacritics in Javascript

In modern browsers and node.js you can use unicode normalization to decompose those characters followed by a filtering regex. str.normalize(‘NFKD’).replace(/[^\w]/g, ”) If you wanted to allow characters such as whitespaces, dashes, etc. you should extend the regex to allow them. str.normalize(‘NFKD’).replace(/[^\w\s.-_\/]/g, ”) var str=”áàâäãéèëêíìïîóòöôõúùüûñçăşţ”; var asciiStr = str.normalize(‘NFKD’).replace(/[^\w]/g, ”); console.info(str, asciiStr); NOTES: This method does … Read more

How to change diacritic characters to non-diacritic ones [duplicate]

Since no one has ever bothered to post the code to do this, here it is: // \p{Mn} or \p{Non_Spacing_Mark}: // a character intended to be combined with another // character without taking up extra space // (e.g. accents, umlauts, etc.). private readonly static Regex nonSpacingMarkRegex = new Regex(@”\p{Mn}”, RegexOptions.Compiled); public static string RemoveDiacritics(string text) … Read more