Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    238
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Replacing Word double quotes

    Hi all,

    I'm having a real struggle trying to replace the double quotes MS Word puts in.
    In the database they appear as forward-leaning double quotes but when output in the web browser they appear as question marks, even in the source code.

    Here is what they look like:
    Code:
    I've tried copying the character directly from the database and doing a str_replace to a correct double quote. I've also tried functions that remove all MS Word html formatting, strip_tags() and htmlentities().
    However, the character always appears as a question mark.

    I would have expected it to show as a strange character in the browser without any conversions taking place.

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Posts
    238
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Its doing the same with forward-leaning single quotes

    Code:

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I would have expected it to show as a strange character in the browser without any conversions taking place.
    Make the mysql connection charset as utf-8 before any insert or fetch into/from the DB.

    You may do it by executing the following statement after the DB selection query
    PHP Code:
    mysql_query("SET NAMES 'utf8'"); 
    Also, add(or replace, if you have another one) the following meta tag into your document's <head> tag
    Code:
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    Hope, this would solve the issue.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    Regular Coder
    Join Date
    Sep 2007
    Posts
    238
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks for the reply.

    I'm using Oracle databases so I dont think I can use mysql_query("SET NAMES 'UTF8'");

    I already have the header set to utf8.

  • #5
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,294
    Thanks
    13
    Thanked 345 Times in 341 Posts
    those characters are the typographical quotation marks found at code points U+2018 to U+201F, which require UTF/UCS to display.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by htcilt View Post
    I'm using Oracle databases so I dont think I can use mysql_query("SET NAMES 'UTF8'");
    You should have specified it in your OP. Im not familiar with oracle, though the function oci_connect()'s the forth parameter is the character set. Check Example #3 at http://php.net/manual/en/function.oci-connect.php
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    Regular Coder
    Join Date
    Sep 2007
    Posts
    238
    Thanks
    9
    Thanked 0 Times in 0 Posts
    This is very strange.
    It does look like the problem is the character set.
    http://forums.oracle.com/forums/thre...01301&#1001301

    I've tried specifying UTF-8 in the connection:
    Code:
    $conn = oci_connect('username', 'password', 'database', 'UTF8');
    setting php.ini and restarting Apache
    Code:
    default_charset = "UTF-8"
    and using utf8_encode() on the echoed field variables.

    according to http://en.wikipedia.org/wiki/UTF-8 the question mark is a replacement character for U+003F.

    Does anyone have any suggestions?

  • #8
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,294
    Thanks
    13
    Thanked 345 Times in 341 Posts
    Quote Originally Posted by htcilt View Post
    according to http://en.wikipedia.org/wiki/UTF-8 the question mark is a replacement character for U+003F.
    erm, U+003F is the question mark. the replacement character is U+FFFD, but that can’t be displayed in ISO/ANSI/ASCII charsets.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #9
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I've tried specifying UTF-8 in the connection:
    Code:

    $conn = oci_connect('username', 'password', 'database', 'UTF8');
    Have you read my above post and the example specified?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #10
    Regular Coder
    Join Date
    Sep 2007
    Posts
    238
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Have you read my above post and the example specified?
    Yes, I've tried the following character sets in the connection (4th parameter):

    AL32UTF8
    UTF8
    WE8ISO8859P15

    The 3rd post from the bottom of http://php.net/manual/en/function.oci-connect.php says to use WE8ISO8859P15 or one will get an upside-down question mark.
    I get an upside-down question mark when querying using sqlplus. This is easy to capture and replace.
    Its only through PHP I get a normal question mark and I cannot replace this as the question mark may be genuine.


  •  

    Posting Permissions

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