#19154 [Opn->Csd]: Include "encoding" argument in utf8_encode function

From: Date: Wed, 28 Aug 2002 16:47:16 +0000
Subject: #19154 [Opn->Csd]: Include "encoding" argument in utf8_encode function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18062@lists.php.net to get a copy of this message
ID: 19154 Updated by: wez@php.net Reported By: dimitris@ccf.auth.gr -Status: Open +Status: Closed Bug Type: Feature/Change Request PHP Version: 4.2.2 New Comment: Try using mb_convert_encoding in the mbstring extension. Previous Comments: ------------------------------------------------------------------------ [2002-08-28 11:38:05] dimitris@ccf.auth.gr 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 this bug report at http://bugs.php.net/?id=19154&edit=1

« previous php.bugs (#18062) next »