php-i18n Digest 25 Jun 2003 20:35:21 -0000 Issue 181

Topics (messages 581 through 582):

mb_detect_encoding bug?
        581 by: Jean-Christian IMbeault

Japanese text not displaying correctly.
        582 by: Dennis browne

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I've just run into a strange "bug". I have a form on my web site that
(Btakes input from the user and then uses that to do a search of a
(Bpostgresql database.
(B
(BThe form is set to be EUC-JP, but this weekend a user submitted a query
(Bthat postgres reject because it "contains invalid EUC-JP" characters.
(BLuckily the error was logged and I was able to track it down.
(B
(BI thought that maybe the user had entered some bad characters in the
(Bform or used some strange encoding so I should better check to make sure
(Bthat the encoding of the submitted form data really is EUC-JP using
(Bmb_detect_encoding(). But unfortunately mb_detect_encoding() says that
(Bthe invalid string *is* in EUC-JP!?
(B
(BThe query string is as it appears in the URL is:
(B
(Bsearch_words=%B7%F6%BA%7E
(B
(BIn the script that parses this query I have put the following:
(B
(B$words = $_GET["search_words"];
(B$enc = mb_detect_encoding($aI["search_words"]);
(Becho "encoding is $enc and the query is ($words)";die;
(B
(BThe result is:
(B
(Bencoding is EUC-JP and the query is ($B7v(B?)
(B
(BAs you can see the query string is *not* a valid EUC-JP sequence ...
(B
(BIs there any way for me to check the user input to make sure it is a
(Bvalid EUC-JP sequence before passing it off to my database?
(B
(BI though that mb_detect_encoding() would be the function to use but it
(Bfails in this case.
(B
(BAny suggestions?
(B
(BThanks,
(B
(BJen-Christian Imbeault

--- End Message ---
--- Begin Message ---
I want to display Japanese text on my site and am having many problems.

I am using Linux Redhat 8, PHP 4.2.

Basically what I have is a file page.php with the following code:

page.php:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Content-Language" content="ja">
</head>
<body>Home:<br>
<?php
include("lng_page_ja.php"); 

echo "home in japanese:"; 
echo "<br><br>$home"; 

?> 
</body>
</html>

I then have an include file with the Japanese text assigned to the
variable $home.

lng_page_ja.php:
<?php
$home = "ホーãƒ"; 

?> 

This should output the japanese characters for Home. But all I get is
garbage out.

Why?

What changes dfo I have to do. I do not want to use a database yet to
store the Japanese text.

Any help would be appreciated.

Dennis


--- End Message ---

Reply via email to