pascal_22 Posted August 31, 2012 Share Posted August 31, 2012 Hello, I have a website. in fact i developp a new design for my web site and i set the meta tag like this <meta charset="utf-8"> : so my accents appears. i replace my accent with the good html accent ?=é ..... But in some page, the city name don't display accented charator well. It replace it by '?' BUT in MySql database, i see correctly the accent.... ? Why? and how show i setup mu database to only be in utf-8...? Thank a lot!! Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/ Share on other sites More sharing options...
hakimserwa Posted August 31, 2012 Share Posted August 31, 2012 question not clear enough? can you try to break it up a bit please Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1374329 Share on other sites More sharing options...
Jessica Posted August 31, 2012 Share Posted August 31, 2012 have you tried using the uft8encode functions on the text when displaying it? Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1374333 Share on other sites More sharing options...
pascal_22 Posted August 31, 2012 Author Share Posted August 31, 2012 Yeah i tried encode and decode for the accent whi are not displayed correctly.. but no success i mean, should i replace all accent in by its html accent before store it in my db?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1374336 Share on other sites More sharing options...
Jessica Posted August 31, 2012 Share Posted August 31, 2012 How about htmlentities, again on output, with the UTF-8 flag? Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1374341 Share on other sites More sharing options...
Christian F. Posted August 31, 2012 Share Posted August 31, 2012 I'd also recommend to use a proper HTTP header, instead of the HTML meta-tag. The reason for this is that the HTTP header overwrites the meta-tag, so if the server is sending out content-type: text/html; charset=ISO-8859-1 by default your meta-tag won't do anything. Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1374375 Share on other sites More sharing options...
premiso Posted September 1, 2012 Share Posted September 1, 2012 The reason for this is that the HTTP header overwrites the meta-tag Can you provide a source to this? I really doubt that the header would overwrite the META tag as that would be rendered last and surely take precedence. As to the Original Post: Make sure your database tables / columns are also set to UTF8 as well as the form that submits the data to the database. If any of them (output / input / storage) are not UTF8 you will get undesired results. Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1374416 Share on other sites More sharing options...
Christian F. Posted September 1, 2012 Share Posted September 1, 2012 premiso: It is quite easy to verify this yourself, you know. All it takes is saving a site as UTF-8, declaring it as some other charset in the HTTP headers, and use the correct in the meta-tag. To be fair I should have written "overrides", not "overwrites". As the former would be 100% correct and accurate, contrary to the latter. Alternatively you can check out either this thread on WebmasterWorld or the one on StackOverflow. I'm sure there are lots of other sources that will confirm this as well. I also recommend the article "Handling character encodings in HTML and CSS" on W3.org, while it may not explicitly state that HTTP headers take precedence over meta-tags there is a lot of useful information in it. Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1374503 Share on other sites More sharing options...
pascal_22 Posted September 6, 2012 Author Share Posted September 6, 2012 yeah thanks to all... i think the problem is that in my html page i encode in utf-8 and in my database all text field is in latin1_swedish... Is that wrong...? thanks a lot Pascal Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1375780 Share on other sites More sharing options...
Christian F. Posted September 6, 2012 Share Posted September 6, 2012 Yes, that's wrong. Make sure that everything uses UTF-8, and you'll see that your work becomes that much easier all of a sudden. Easiest way to convert your database is to make a dump of it, then modify the dump-script to use SET NAMES 'utf8'; at the top, and DEFAULT CHARSET=utf8 at the end of every table definition. Then, after testing that it actually works, drop the old database and import the script anew. If you cannot shut down your page while doing this, or if you're in danger of losing data if you do it in this way, then it is possible to update a live database. It's a far more complex and brittle process, however, and as such I do not recommend it. So only contemplate it if there is no other way. Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1375884 Share on other sites More sharing options...
pascal_22 Posted September 19, 2012 Author Share Posted September 19, 2012 Ok great!!! I'll do that!! Thanks a lot for your help! I really appreciate!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1379230 Share on other sites More sharing options...
Christian F. Posted September 19, 2012 Share Posted September 19, 2012 You're welcome, and I'm glad I could help. Quote Link to comment https://forums.phpfreaks.com/topic/267862-php-some-page-my-accented-char-appear-and-some-pages-no-and-replaced-by/#findComment-1379233 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.