473,785 Members | 2,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unicode generated by php [iconv()] doesn't show properly

I need help with utf-8 before i go bald and the rest of my hair turns
white!

Platform:
Mac OS X 10.2.6
Safari 1.0 (v85)
Internet Explorer:mac 5.2.3 (5815.1)
Apache 2.0.47
PHP 4.3.2 (Apache 2 module)
libiconv 1.8

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dt d">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Unicod e Test</title>
</head>
<body><p>
<?php
$macRom = 'métallique arquée'; // typed in a bbedit for mac
echo iconv('MacRoman ', 'UTF-8', $macRom);
?>
</p></body></html>

When I run this script, I get, both in Safari and Explorer,
métallique arquée
and not
métallique arquée

But, that's why I'm going crazy, *if* I save this output as an html
file and load it in Safari, *it shows the proper accents*!

Now, can somebody please explain me why a page generated using PHP is
behaving differently from the very same output of that page? What am I
missing?

Thank you all.
Jul 16 '05 #1
3 2675
In article <4c************ **************@ posting.google. com>, one of infinite monkeys
at the keyboard of er**@tba.com.br (Erik Neves) wrote:
behaving differently from the very same output of that page? What am I
missing?


At a guess, maybe your server is setting a different charset.
Last time I looked, Apache defaults to iso-8859-1 unless you
tell it to do otherwise.

--
Nick Kew

In urgent need of paying work - see http://www.webthing.com/~nick/cv.html
Jul 16 '05 #2
On Thu, Aug 28, Erik Neves inscribed on the eternal scroll:
Please disregard this post.
I could resist that invitation ;-)
I alredy found the answer.
You already found _an_ answer, it seems. And a good one, in practical
terms, but it still leaves some details unclear.
FWIMC, I just added a

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

before any content and everything worked just fine.
It should do...
It seems that the
tag
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
is not enough.
Which is exactly what Appendix C to XHTML/1.0 says: it is not enough.

Even with HTML, there is an issue: if the server is configured to send
a different charset than what you put into META, then what the server
sent is specified to take priority. So you need to keep control of
your server anyway, and the W3C recommend (rightly so, in my opinion)
to use the server's real HTTP header on the transaction, in preference
to using (or trying to use) meta stashed inside the document.

But in XHTML (which is what you're evidently aiming at), "meta" comes
too late, and means nothing (to XHTML). You'd only put it there (if
you use it at all) in XHTML/1.0, for the reason of compatibility with
older browsers (and other user agents), but for XHTML you'd need to
conform with XML's rules also, as set out in Appendix C. And here
again, life is simplest if you use the real HTTP content-type header
to specify your character encoding (that so-called "charset"
parameter).
Now I can have a site with a Russian interface and Japanese contents,
just for the fun of it! Thanks to Unicode.


And some right-to-left scripts for a dessert. ;-)

cheers

(f'ups narrowed - this isn't a specifically PHP issue.)
Jul 16 '05 #3
joncarlo1
1 New Member
You need to change the apache server config from:
AddDefaultChars et UTF-8

to

AddDefaultChars et ISO-8859-1

Then restart Apache webserver

/etc/httpd/conf/httpd.conf

That should take care of it.

JC
Jun 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1942
by: Stuart Gerchick | last post by:
When will PHP properly support UNICODE
3
5077
by: pbuchheit | last post by:
I need to convert Japanese characters to UTF-8. I tried using this command on a PHP 5.0.3 server: $out = iconv("iso-2022-jp", "utf-8", $in); But it does not work. Can anyone tell me what I'm doing wrong? (Note: I also tried this, unsuccessfully, with Chinese characters: $out = iconv("gb2312", "utf-8", $in); )
4
2715
by: gabor | last post by:
hi, today i made some tests... i tested some unicode symbols, that are above the 16bit limit (gothic:http://www.unicode.org/charts/PDF/U10330.pdf) .. i played around with iconv and so on, so at the end i created an utf8 encoded text file,
10
2409
by: Dumbkiwi | last post by:
I'm trying to get python, unicode and kdialog to play nicely together. This is a linux machine, and kdialog is a way to generate dialog boxes in kde with which users can interact (for example input text), and you can use the outputted text in your script. Anyway, what I'm doing is reading from a utf-8 encoded text file using the codecs module, and using the following: data = codecs.open('file', 'r', 'utf-8')
22
5497
by: Keith MacDonald | last post by:
Hello, Is there a portable (at least for VC.Net and g++) method to convert text between wchar_t and char, using the standard library? I may have missed something obvious, but the section on codecvt, in Josuttis' "The Standard C++ Library", did not help, and I'm still awaiting delivery of Langer's "Standard C++ IOStreams and Locales". Thanks,
2
2672
by: Erik Neves | last post by:
I need help with utf-8 before i go bald and the rest of my hair turns white! Platform: Mac OS X 10.2.6 Safari 1.0 (v85) Internet Explorer:mac 5.2.3 (5815.1) Apache 2.0.47 PHP 4.3.2 (Apache 2 module) libiconv 1.8
4
2018
by: Tony Nelson | last post by:
Is there a faster way to decode from charmaps to utf-8 than unicode()? I'm writing a small card-file program. As a test, I use a 53 MB MBox file, in mac-roman encoding. My program reads and parses the file into messages in about 3..5 seconds, but takes about 13.5 seconds to iterate over the cards and convert them to utf-8: for i in xrange(len(cards)): u = unicode(cards, encoding) cards = u.encode('utf-_8')
2
9324
by: David Lutz | last post by:
Hello, I want to convert an existing database with SQL_ASCII encoding to UNICODE encoding. (postgresql ver 7.3.2) I thought that it might be as easy as: pg_dump mydatabase > dump.sql createdb --encoding=unicode newdatabase psql newdatabase < dump.sql
6
12550
by: Aneesh E Warrier | last post by:
How can I convert Unicode Codepoint (dec) value to ASCII char? For example: 49324 is 사 a Korean alphabet, and I want to convert it to ASCII letter. Thanks!
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.