PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #6492

UTF8 encoded Database data

Details

Request #6492UTF8 encoded Database data
Submitted2006-01-14 19:02 UTC
FromSuttnerBernhard at web dot de
StatusFeedback
PackageDB_DataObject
PHP Version5.1.1
OSFedora Core 4
Roadmaps(Not assigned)

Comments

[2006-01-14 19:02 UTC] SuttnerBernhard at web dot de

Description:
------------
Helo,
I am using DB DataObject 1.8.0 (yeah, this modul rules!!!!). I have
found a problem (maybe a bug) with utf8. My database is a mysql 4.1.16.

I have set the database collation and the table field collation to
utf8_general_ci. I have a string "Fußball" in the table field "name". I don´t get a result if a search for "Fußball". I have add a sample in the "Test Script" section.

Test script:
---------------
If i do the following:
$abteilung = DB_DataObject::factory('Abteilung');

$abteilung->whereAdd("name='Tischtennis'");
$abteilung->whereAdd("name='Leichtathletik'", "OR");
$abteilung->whereAdd("id='1'", "OR");
$abteilung->find();

echo "<pre>";
print_r($abteilung);
echo "</pre>";

echo "<br />";
while ($abteilung->fetch()) {
echo "$abteilung->id} {$abteilung->name}<BR>";
}

I get:
--
1} Fu�ball
2} Tischtennis
3} Leichtathletik

Expected result:
----------------
I expected :
--
1} Fußball
2} Tischtennis
3} Leichtathletik

See ascii table:
ß ÃŸ ß scharfes ß

--

Perhaps all strings should be utf8 handled, so check every string if it is utf8 encoded, if not encode it. A

workarounds:

1)
$abteilung->whereAdd("name='".utf8_decode("Fußball")."'", "OR");

2)
echo "$abteilung->id} {".utf8_encode($abteilung->name)."}<BR>";

Actual result:
--------------
I get:
--
1} Fu�ball
2} Tischtennis
3} Leichtathletik