Jump to content

special characters practice vs. theory ??


bad_gui

Recommended Posts

I have a journal article DB project that I coded at home.  The database character set is UTF-8

since some author names are foreign. I switched my browser's default font to utf-8. The php code

includes

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Virtual Library</TITLE>
<STYLE TYPE="text/css">

 

Everything works great at home.  When I installed this at work for general use, I found internet exploder

doesn't allow a permanent change to the default character encoding.  It also ignores the code above even

when I set the encoding to "autodetect" Even if I manually set utf-8, every time I browse away the default

is reset to Western (ISO-8859-1 I think).  So now the old entries I transfered by mysqldump are mangled when

viewing with Western, but the new entries are mangled when viewing with utf-8.  I can change all to latin1

but this doesn't cover all French, Spanish Swedish etc. characters, no?

 

I tried searching the web but couldn't find how professional developers (I'm an amateur) deal with the

accented character in a mixed browser environment.  Several options are listed in this link but which is

 

http://en.wikipedia.org/wiki/Help:Special_characters 

Link to comment
Share on other sites

since some author names are foreign. I switched my browser's default font to utf-8.

 

First a note - utf-8 is a charset, not a font. Fonts display characters. The characters that exist are determined by the charset. If the character doesn't exist in the charset, then the font cant display it.

 

Next, the (potential) solution to your problem: it sounds like the default charset that php is using is set to iso-8859-1 instead of utf-8. To find out if this is the case, create a file and include the following code in it:

 

<?php phpinfo(); ?>

 

Then run that script on your server. It will print out a whole huge list of all the settings you have for php. Look for default_charset (its probably in the top block of settings) and see what it is set to. If it is set to iso-8859-1, you will need to go into your php.ini and change the default charset to utf-8 in there.

Link to comment
Share on other sites

Sysadmin at work won't change httpd.conf default charset from iso-8859 but I

found a site with useful workaround that solves most of the problem

 

http://www.phpwact.org/php/i18n/charsets

 

So I added the follwing code to the top of index.php and now IE switches to utf-8

when the encoding is set to "auto"  This will display the characters correctly on the

main page but not when other pages are used.

 

// Setting the Content-Type header with charset
header('Content-Type: text/html; charset=utf-8');

 

However, since I am a newbie to php and html I can't figure out how to apply this to

all of the code since some pages still display garbled characters

 

Yuste L, Montero JC, Espar�s-Ogando A, Pandiella A. (2005)

Activation of ErbB2 by overexpression or by transmembrane neuregulin results in differential signaling and sensitivity to herceptin.

Cancer research 65: 6801-10.

 

But when I do a "view source" in the browser it gives

<TABLE BORDER="0" CELLSPACING="5" CELLPADDING="5"><TR><TD><P ALIGN=justify>Yuste L, Montero JC, Esparís-Ogando A, Pandiella A. (2005)<BR>

<B>Activation of ErbB2 by overexpression or by transmembrane neuregulin results in differential signaling and sensitivity to herceptin.</B><BR>

Cancer research <B>65</B>: 6801-10.<BR>

 

Do I add the php code to set the header to utf-8 to every php script?

 

 

Link to comment
Share on other sites

I think you need to go back and re-read my post. I didn't say anything about touching the httpd.conf file, and I gave you what I think is most likely the solution to your problem (I regularly deal with encoding issue due to the fact that I am programming Japanese websites). If you ask for help, you should at least attempt the suggestions you are given.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.