www.webdeveloper.com
Results 1 to 3 of 3

Thread: Characters Encoded Incorrectly

  1. #1
    Join Date
    Feb 2011
    Posts
    38

    Cool Characters Encoded Incorrectly

    Hi guys, really hoping someone can help me out because I'm pulling my hair out over this!!

    My boss keeps writing texts in Word and forwards it on to me to post to our website which I've built but when he puts apostrophies in, they get turned into the wierd characters. The text is inserted into a database by PHP and the apostrophy looks like this in the database... ’

    I am posting the input to the db in the following way...
    PHP Code:
    mysql_query("INSERT INTO table VALUES (
    '"
    .mysql_real_escape_string($text)."'
    )"
    ) or die (mysql_error()); 
    Hope someone can help...

    Thanks in advance

    Smithster

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,225
    Something I came up with some time ago you could try: http://www.charles-reace.com/blog/20...-ms-word-text/

    Note that in this function I also handle the characters converted by htmlspecialchars(), so you don't want to use it in conjunction with that function (or with htmlentities(), for that matter).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Feb 2011
    Posts
    38
    wow thanks Nogdog for a quick response...

    I posted this question on a different forum last night and hadn't had a response back until funny enough just before you! I was told to try this...

    PHP Code:
    mysql_real_escape_string(mb_convert_encoding($text,'HTML-ENTITIES','UTF-8')) 
    It works for the apostrophy I was having trouble with, but I think I'll make use of the function on the page you linked also just incase any other wierd characters end up in there!!

    Thanks again

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles