...

View Full Version : Replacing Word double quotes



htcilt
03-01-2010, 09:35 AM
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:


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.

htcilt
03-01-2010, 09:41 AM
Its doing the same with forward-leaning single quotes



abduraooft
03-01-2010, 09:42 AM
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

mysql_query("SET NAMES 'utf8'"); Also, add(or replace, if you have another one) the following meta tag into your document's <head> tag

<meta http-equiv="Content-Type" content="text/html;charset=utf-8">

Hope, this would solve the issue.

htcilt
03-01-2010, 10:09 AM
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.

Dormilich
03-01-2010, 10:35 AM
those characters are the typographical quotation marks found at code points U+2018 to U+201F, which require UTF/UCS to display.

abduraooft
03-01-2010, 11:06 AM
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

htcilt
03-01-2010, 03:00 PM
This is very strange.
It does look like the problem is the character set.
http://forums.oracle.com/forums/thread.jspa?messageID=1001301&#1001301

I've tried specifying UTF-8 in the connection:

$conn = oci_connect('username', 'password', 'database', 'UTF8');

setting php.ini and restarting Apache

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?

Dormilich
03-01-2010, 03:07 PM
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.

abduraooft
03-01-2010, 03:08 PM
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?

htcilt
03-01-2010, 04:03 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum