0

I have some weird problems with encoding my Wordpress website and I can't add comments with accent words. when i try to do it, i received error by WP.

What i need is just a function that read the comment before it has inserted and transforms all the accented characters with normal characters with no accents. And where i have to use the function? which WP core files?

I tried to use functions like htmlentities or mb_convert_encoding but i don't know where i have to use them and i have some trouble because half site is in UTF-8 and the other part is in ISO-8859-1… so i need a simple function that replace all the accent characters as i wrote above, with no encoding stuff.

1

Use the proper charset in you website according with the characters you use, that is the correct solution from my point of view. What your are trying is some work around that don't fix the real issue.

You must note that UTF-8 is the standard enconding recommend for internet nowdays. ISO-8859-1 was considered the standard for 4.01, although most of the websites went with UTF-8 because of the enconding problems ISO-8859-1 had. In XML and HTML5, UTF-8 is the default character set as it is for WordPress since version 3.5. Even further, WP 4.2 will use, when possible, utf8mb4 in database (four-byte UTF-8 encoding, previously it was using utf8mb3) to handle the full range of Unicode characters.

Also, from a practical point of view, it is easier to change the enconding charset of the website than filtering the comments and I tink you will have advantages and no disadvantages.

PD: You may be facing a XY problem in your question. You ask about your intended solution (filtering comments) when your real problem is another (using the correct enconding).

  • yep i definitely agree, but it's a temporarily work around that i need while i'm working on the new theme that support UTF-8.. my first goal is change the encode but now i can't do it fast. this is why i need that function – Amaca Apr 23 '15 at 11:02
  • Your problem doesn't seem related with the theme. Using ISO-8859-1 charset in theme (I mean, for HTML) would make accented characters looking wierd or not visible at all, but nothing to do with accepting or rejecting comments with accented characters. It maybe related with database charset (not sure). If you have problems converting charset of your WordPress installation from ISO-8859-1 to UTF-8, post a question about that. A tutorial to start in the codex: Converting Database Character Sets. – cybmeta Apr 23 '15 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.