[PHP] I18n problems: Working with double-byte languages
Hi people ! I have a query regarding double-byte languages on PHP. I need to sort a index localized from English to Korean. My idea is: * get the Korean strings from file; * convert them to UTF8; * insert them in a Oracle database set to work with UTF8; * set NLS_LANG with Alter session SQL command to this variable match with Korean language; * get the strings sorted by Oracle with a SELECT * FROM table SORT BY field ASC SQL command; I've tried to convert the Korean string to UTF8 with utf8_encode function, but this function converted each byte from double-byte string to its relative in UTF8 chars. Reverting this string encoded to UTF8 with utf8_decode function, the browser can display successfully the Korean chars (because the individual bytes of the double-byte string will be as them were before), but Oracle can't sort the strings properly because that UTF8 chars converted by utf8_encode function were not relative to a double-byte char, but relative to a 2 single bytes chars! How can I convert a double-byte string to UTF8 properly??? Really thanks _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] www.bowneglobal.com.br http://www.bowneglobal.com.br/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session troubles
Hi Sean ! I had the same problem... this can be resolved using the function session_write_close() at the end of each script you use sessions. It will force PHP to call the write and close function. In some combinations of PHP version, Apache and OS, this problem doesn't happens, but as you, I had this problem too.. :) Put this function in yours PHP scripts and see if now them will work. Here is an exemple of a test script: ?php error_reporting( E_ALL ); ini_set(session.save_handler,user); include( ./mysession.php ); where is my session functions declareted to use database... session_start(); ? html head titleMySQL Session Management: Second Page/title /head body ?php print( SESSION User: $aUserbr ); print( SESSION Account: $aAccountbr ); $aUser = Katie; $aAccount = 2026; print( CHANGED User: $aUserbr ); print( CHANGED Account: $aAccountbr ); session_write_close(); ? /body /html Cheers, _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 2:20 PM To: [EMAIL PROTECTED] Subject:Re: [PHP] Session troubles On 01-02 07:45, Jaime Bozza wrote: I agree. Perhaps make a feature request that disallows session starting if save_handler=user and you haven't defined a session handler?Then it could spit out a more correct error message. Blast. I am still unable to get my own session handler to work. My session handler's write never gets called; only my session_open and session_read get calledthe default file session handler still works, if I change save_handler back to file instead of user. As for the feature request, I guess I could - is there a mechanism to do this outlined somewhere? -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 01, 2002 8:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session troubles On 12-31 09:23, Jaime Bozza wrote: Sean, From your php error_log, it's saying the following: Failed to write session data (user) which sounds like it's having problems writing to the user-defined session handler. Are you using a user-defined session handler? If not, make sure your php.ini file has: session.save_handler = files And *NOT*: session.save_handler = user That will make a big difference. Good eye. That was it. I *did* have it as user because I was trying to do my own user-defined session handler, and then stepped back and was just trying to get the simpler case to work, w/o changing it back. Thanks, it works now! Now, I just need to see if I can get my session_handler working... It's too bad the error message isn't more descriptive for this, BTW... -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Saturday, December 29, 2001 1:21 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session troubles On 12-29 12:56, David Jackson wrote: Sean -- Don't know if this help but here's what I just worked for me. What ver. of PHP are you using? It seem to me that 3.x.x needs PHPLIB: http://sourceforge.net/projects/phplib to handle sessions? -- David Jackson --- sean.php --- ?php include(seaninc.php); ? --- seaninc.php -- ?php session_start(); session_register(i); $i++; echo $i; ? I'm using 4.0.6. I believe session handling was added as part of standard 4.x, right (if configured to compile it)? Some more info: I tried with Konqueror, as I know a cookie needs to be sent during the session_start() phase - I did get a dialog pop-up asking if I wanted to accept the cookie, but I still got the error: Fatal error: Failed to initialize session module in /usr/local/apache/htdocs/sesstest.php on line 2 It says line 2 because I deleted some white space and commented out code thas was before session_start(). I set logging errors on, and sent it to syslog. Here's what it says: Dec 29 12:12:57 free httpd: PHP Fatal error: Failed to initialize session module in /usr/local/apache/htdocs/sesstest.php on line 2 Dec 29 12:12:57 free httpd: PHP Warning: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 But /tmp exists, and is world writeable: free# ls -ld /tmp drwxrwxrwt 16 root wheel 1024 Dec 29 12:14 /tmp On 12-29 09:59, Miles Thompson wrote: Sean, What's going on in incl.php. Are you issuing a session_start()? No, I was not. What if it's rearranged like so, as I understand you have to register the session variable before using it. include(incl.php); session_start();
RE: [PHP] Session troubles
Ok Jaime. I've imagine that he had the same problem that I have had before.. :) I'm really returning a ' in my read function when there is no data too... because of this I don't had the problem related by Sean... Thanks, _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Jaime Bozza [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 11:09 AM To: [EMAIL PROTECTED] Subject:RE: [PHP] Session troubles Ricardo, I've had some strange problems with session writing, but they always returned back to the fact that return false was being used in the session read function. PHP 4.0.6 wouldn't write out sessions when register_globals was set to off when you were using return false. PHP 4.1.0 crashes with signal 11 after a bit when using return false. I've filed a couple of bug reports with the request that this be fixed. I believe a patch is either being worked on or already submitted, but I'm not positive. Sean's problem is that he's using return false in his session read function. The session read function should return a blank value ('') and not false when there's no data. This was never clear in the documentation (and complaint I made) but is quite true. Once switching over to using ('') instead of (false), I no longer had problems. Jaime Bozza -Original Message- From: Junior, Ricardo [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 8:52 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Session troubles Hi Sean ! I had the same problem... this can be resolved using the function session_write_close() at the end of each script you use sessions. It will force PHP to call the write and close function. In some combinations of PHP version, Apache and OS, this problem doesn't happens, but as you, I had this problem too.. :) Put this function in yours PHP scripts and see if now them will work. Here is an exemple of a test script: ?php error_reporting( E_ALL ); ini_set(session.save_handler,user); include( ./mysession.php ); where is my session functions declareted to use database... session_start(); ? html head titleMySQL Session Management: Second Page/title /head body ?php print( SESSION User: $aUserbr ); print( SESSION Account: $aAccountbr ); $aUser = Katie; $aAccount = 2026; print( CHANGED User: $aUserbr ); print( CHANGED Account: $aAccountbr ); session_write_close(); ? /body /html Cheers, _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 2:20 PM To: [EMAIL PROTECTED] Subject:Re: [PHP] Session troubles On 01-02 07:45, Jaime Bozza wrote: I agree. Perhaps make a feature request that disallows session starting if save_handler=user and you haven't defined a session handler? Then it could spit out a more correct error message. Blast. I am still unable to get my own session handler to work. My session handler's write never gets called; only my session_open and session_read get calledthe default file session handler still works, if I change save_handler back to file instead of user. As for the feature request, I guess I could - is there a mechanism to do this outlined somewhere? -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 01, 2002 8:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session troubles On 12-31 09:23, Jaime Bozza wrote: Sean, From your php error_log, it's saying the following: Failed to write session data (user) which sounds like it's having problems writing to the user-defined session handler. Are you using a user-defined session handler? If not, make sure your php.ini file has: session.save_handler = files And *NOT*: session.save_handler = user That will make a big difference. Good eye. That was it. I *did* have it as user because I was trying to do my own user-defined session handler, and then stepped back and was just trying to get the simpler case to work, w/o changing it back. Thanks, it works now! Now, I just need to see if I can get my session_handler working... It's too bad the error message isn't more descriptive for this, BTW... -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Saturday, December 29, 2001 1:21 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session troubles On 12-29 12:56, David Jackson wrote: Sean -- Don't know if this help but here's what I just worked for me. What ver. of PHP are you using? It seem to me that 3.x.x needs PHPLIB: http://sourceforge.net/projects
RE: [PHP] Session troubles
I was using 4.06 version... but I don't test this issues with 4.1 version in my system (linux Mandrake 8.1)... I will test and let you know! :) _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Jaime Bozza [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 11:38 AM To: [EMAIL PROTECTED] Subject:RE: [PHP] Session troubles Hmmm... So, there are yet more problems with the session functions. :) Are you using 4.1.1 or 4.0.6? Jaime -Original Message- From: Junior, Ricardo [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 9:34 AM To: 'Jaime Bozza'; [EMAIL PROTECTED] Subject: RE: [PHP] Session troubles Ok Jaime. I've imagine that he had the same problem that I have had before.. :) I'm really returning a ' in my read function when there is no data too... because of this I don't had the problem related by Sean... Thanks, _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Jaime Bozza [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 11:09 AM To: [EMAIL PROTECTED] Subject:RE: [PHP] Session troubles Ricardo, I've had some strange problems with session writing, but they always returned back to the fact that return false was being used in the session read function. PHP 4.0.6 wouldn't write out sessions when register_globals was set to off when you were using return false. PHP 4.1.0 crashes with signal 11 after a bit when using return false. I've filed a couple of bug reports with the request that this be fixed. I believe a patch is either being worked on or already submitted, but I'm not positive. Sean's problem is that he's using return false in his session read function. The session read function should return a blank value ('') and not false when there's no data. This was never clear in the documentation (and complaint I made) but is quite true. Once switching over to using ('') instead of (false), I no longer had problems. Jaime Bozza -Original Message- From: Junior, Ricardo [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 8:52 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Session troubles Hi Sean ! I had the same problem... this can be resolved using the function session_write_close() at the end of each script you use sessions. It will force PHP to call the write and close function. In some combinations of PHP version, Apache and OS, this problem doesn't happens, but as you, I had this problem too.. :) Put this function in yours PHP scripts and see if now them will work. Here is an exemple of a test script: ?php error_reporting( E_ALL ); ini_set(session.save_handler,user); include( ./mysession.php ); where is my session functions declareted to use database... session_start(); ? html head titleMySQL Session Management: Second Page/title /head body ?php print( SESSION User: $aUserbr ); print( SESSION Account: $aAccountbr ); $aUser = Katie; $aAccount = 2026; print( CHANGED User: $aUserbr ); print( CHANGED Account: $aAccountbr ); session_write_close(); ? /body /html Cheers, _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 2:20 PM To: [EMAIL PROTECTED] Subject:Re: [PHP] Session troubles On 01-02 07:45, Jaime Bozza wrote: I agree. Perhaps make a feature request that disallows session starting if save_handler=user and you haven't defined a session handler? Then it could spit out a more correct error message. Blast. I am still unable to get my own session handler to work. My session handler's write never gets called; only my session_open and session_read get calledthe default file session handler still works, if I change save_handler back to file instead of user. As for the feature request, I guess I could - is there a mechanism to do this outlined somewhere? -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 01, 2002 8:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session troubles On 12-31 09:23, Jaime Bozza wrote: Sean, From your php error_log, it's saying the following: Failed to write session data (user) which sounds like it's having problems writing to the user-defined session handler. Are you using a user-defined session handler? If not, make sure your php.ini file has: session.save_handler = files And *NOT*: session.save_handler = user That will make a big
RE: [PHP] Session troubles
This was problem that I had: the function write was not been called by PHP sessions functions when a script finish or when I change the variable contents. Searching on PHP.net I saw this solution there: add a call to function session_write_close() at the end of the php code. This should be another problem with Sessions functions... but I need to test this with PHP 4.1... Thanks, _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Alok K. Dhir [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 12:56 PM To: 'Jaime Bozza'; [EMAIL PROTECTED] Subject:RE: [PHP] Session troubles FYI - I can confirm Jaime's assertion. I too had the exact same issue with the exact same fix. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]. net] On Behalf Of Jaime Bozza Sent: Thursday, January 03, 2002 9:09 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Session troubles Ricardo, I've had some strange problems with session writing, but they always returned back to the fact that return false was being used in the session read function. PHP 4.0.6 wouldn't write out sessions when register_globals was set to off when you were using return false. PHP 4.1.0 crashes with signal 11 after a bit when using return false. I've filed a couple of bug reports with the request that this be fixed. I believe a patch is either being worked on or already submitted, but I'm not positive. Sean's problem is that he's using return false in his session read function. The session read function should return a blank value ('') and not false when there's no data. This was never clear in the documentation (and complaint I made) but is quite true. Once switching over to using ('') instead of (false), I no longer had problems. Jaime Bozza -Original Message- From: Junior, Ricardo [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 8:52 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Session troubles Hi Sean ! I had the same problem... this can be resolved using the function session_write_close() at the end of each script you use sessions. It will force PHP to call the write and close function. In some combinations of PHP version, Apache and OS, this problem doesn't happens, but as you, I had this problem too.. :) Put this function in yours PHP scripts and see if now them will work. Here is an exemple of a test script: ?php error_reporting( E_ALL ); ini_set(session.save_handler,user); include( ./mysession.php ); where is my session functions declareted to use database... session_start(); ? html head titleMySQL Session Management: Second Page/title /head body ?php print( SESSION User: $aUserbr ); print( SESSION Account: $aAccountbr ); $aUser = Katie; $aAccount = 2026; print( CHANGED User: $aUserbr ); print( CHANGED Account: $aAccountbr ); session_write_close(); ? /body /html Cheers, _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 2:20 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session troubles On 01-02 07:45, Jaime Bozza wrote: I agree. Perhaps make a feature request that disallows session starting if save_handler=user and you haven't defined a session handler? Then it could spit out a more correct error message. Blast. I am still unable to get my own session handler to work. My session handler's write never gets called; only my session_open and session_read get calledthe default file session handler still works, if I change save_handler back to file instead of user. As for the feature request, I guess I could - is there a mechanism to do this outlined somewhere? -Original Message- From: Sean LeBlanc [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 01, 2002 8:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session troubles On 12-31 09:23, Jaime Bozza wrote: Sean, From your php error_log, it's saying the following: Failed to write session data (user) which sounds like it's having problems writing to the user-defined session handler. Are you using a user-defined session handler? If not, make sure your php.ini file has: session.save_handler = files And *NOT*: session.save_handler = user That will make a big difference. Good eye. That was it. I *did* have it as user because I was trying to do my own user-defined session handler, and then stepped back and was just
[PHP] LIBXML- Auto-Indent - How do it?
Hi All, I would like to know if there is any way to auto-indent the XML file when I add a new node in a docxml object and export the string of the created XML file with dumpmem() function... For example: $new = new_xmldoc(1.0); $root = $new-add_root(ROOT); $level1 = $root-new_child(LEVEL-1, ); $level1-new_child(LEVEL2, ); $new_xml_file = fopen (test.xml, w); fwrite($new_xml_file, $new-dumpmem()); fclose ($new_xml_file); The result in test.xml file is: ?xml version=1.0? ROOTLEVEL-1LEVEL2//LEVEL-1/ROOT But I'm needing it like this: ?xml version=1.0? ROOT LEVEL-1 LEVEL2/ /LEVEL-1 /ROOT Could someone help me on this?! Thanks. _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] www.bowneglobal.com.br http://www.bowneglobal.com.br/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] LIBXML- Auto-Indent - How do it?
The conversion to plain text mail format changed the correct indent that I need I'm needing it like this: ROOT LEVEL-1 LEVEL2/ /LEVEL-1 /ROOT Thanks !!! _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] www.bowneglobal.com.br -Original Message- From: Junior, Ricardo [mailto:[EMAIL PROTECTED]] Sent: Monday, December 17, 2001 10:48 AM To: '[EMAIL PROTECTED]' Subject:[PHP] LIBXML- Auto-Indent - How do it? Hi All, I would like to know if there is any way to auto-indent the XML file when I add a new node in a docxml object and export the string of the created XML file with dumpmem() function... For example: $new = new_xmldoc(1.0); $root = $new-add_root(ROOT); $level1 = $root-new_child(LEVEL-1, ); $level1-new_child(LEVEL2, ); $new_xml_file = fopen (test.xml, w); fwrite($new_xml_file, $new-dumpmem()); fclose ($new_xml_file); The result in test.xml file is: ?xml version=1.0? ROOTLEVEL-1LEVEL2//LEVEL-1/ROOT But I'm needing it like this: ?xml version=1.0? ROOT LEVEL-1 LEVEL2/ /LEVEL-1 /ROOT Could someone help me on this?! Thanks. _ Ricardo J. A. Júnior, Software Engineer Trainee Bowne Global Solutions Phone +55 21 2515 7713 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] www.bowneglobal.com.br http://www.bowneglobal.com.br/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]