#19154 [NEW]: Include "encoding" argument in utf8_encode function
| From: | dimitris at ccf dot auth dot gr | Date: | Wed, 28 Aug 2002 15:38:06 +0000 |
| Subject: | #19154 [NEW]: Include "encoding" argument in utf8_encode function | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-18041@lists.php.net to get a copy of this message | ||
From: dimitris@ccf.auth.gr
Operating system:
PHP version: 4.2.2
PHP Bug Type: Feature/Change Request
Bug description: Include "encoding" argument in utf8_encode function
We wanted a way to convert to utf8 strings originating from other than
ISO-8859-1 encodings. Looking through the source code in
PHP_SOURCE/ext/xml/xml.c we found out that the utf8_encode function has
hardwired the ISO-8859-1 encoding method in it, even though the
xml_utf8_encode function has already provisions for choosing another
encoding (if implemented).
See PHP_FUNCTION(utf8_encode):
encoded = xml_utf8_encode(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &len,
"ISO-8859-1");
And see:
static XML_Char *xml_utf8_encode(const char *s, int len, int *newlen,
const XML_
Char *encoding)
If PHP is interested in providing UTF-8 conversion support for other
lanaguages (encodings), then this extra argument is necessary for the user
to be able to indicate originating encoding for the text he is about to
convert. As for utf8_decode, that function does not
need an indication of target encoding since the originating text in
Unicode already specifies language.
I have patched xml.c for ISO-8859-7 and I would be more
than willing to cooperate with anybody who takes this up, share code and
knowledge. I have also posted my "fixes" in the manual page for
utf8_encode.
Thanks.
Dimitris Daskopoulos
NOC, Aristotle University of Thessaloniki
--
Edit bug report at http://bugs.php.net/?id=19154&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=19154&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=19154&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=19154&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=19154&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=19154&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19154&r=support
Expected behavior: http://bugs.php.net/fix.php?id=19154&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=19154&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=19154&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=19154&r=globals