Jabop Posted December 17, 2008 Share Posted December 17, 2008 Hi guys, long time no see. I have a form, with a radio field: <input type="radio" name="radio_name" value="Oui, j’aimerais avoir site en français." /> However, when the form is posted, the value submitted is: Oui, j’aimerais avoir site en français. In turn, prohibits me from comparing the values for validation. I've tried messing with htmlspecialchars/entities, to no avail. How can I preserve the exact value when posting, or, compare them with the "output" value of the characters? Hopefully this description is not too vague. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/ Share on other sites More sharing options...
Jabop Posted December 17, 2008 Author Share Posted December 17, 2008 htmlentities('Oui, j’aimerais avoir site en français.'); returns Oui, jâ��aimerais avoir site en français. which is NOT equal to its original value: Oui, j’aimerais avoir site en français. Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/#findComment-718142 Share on other sites More sharing options...
Rommeo Posted December 17, 2008 Share Posted December 17, 2008 i have exactly the same problem. Could not solve it yet Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/#findComment-718143 Share on other sites More sharing options...
redarrow Posted December 17, 2008 Share Posted December 17, 2008 Give up boys lol header mate. <?php header('Content-Type: text/plain; charset=ISO-8859-1'); echo htmlentities('Oui, j’aimerais avoir site en français.'); ?> Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/#findComment-718152 Share on other sites More sharing options...
Jabop Posted December 17, 2008 Author Share Posted December 17, 2008 redarrow, that suggestion did nothing. It returned Oui, j’aimerais avoir site en français. which is still different from its original radio field value. Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/#findComment-718239 Share on other sites More sharing options...
effigy Posted December 17, 2008 Share Posted December 17, 2008 Have you tried html_entity_decode? I would compare the strings in this fashion since you wouldn't run across an instance of comparing a named entity to a numerical. Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/#findComment-718254 Share on other sites More sharing options...
Mchl Posted December 17, 2008 Share Posted December 17, 2008 Save source files as UTF-8. Set HTML encoding to UTF-8 If needed, set database connection to UTF-8 Works for me. Also take a look at mb_string extension for working with multibyte encoded strings. Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/#findComment-718259 Share on other sites More sharing options...
Jabop Posted December 17, 2008 Author Share Posted December 17, 2008 <?php echo htmlentities('Oui, j’aimerais avoir site en français.',ENT_QUOTES,'UTF-8'); ?> That returns Oui, j’aimerais avoir site en français. I suppose my database value had a different or not standard value for ’ I can change that. Fixed, thanks! Link to comment https://forums.phpfreaks.com/topic/137424-character-encoding-issue/#findComment-718271 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.