Re: [PHP] Re: Converting strings to match multiple charsets
On Thursday 01 July 2004 06:42, Red Wingate wrote: yep, as i said it was displayed correctly everywhere expect in the forms oh i might mention - Mozilla worked well but IE destroyed the data (only in textareas) Just an idea... How about doing something like this: Retrieve data from the db(utf?) then convert it to the desired language encoding for the (HTML) page. ex. for EUC-JP db (utf) - html (EUC-JP) ? - E - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] yep, as i said it was displayed correctly everywhere expect in the forms oh i might mention - Mozilla worked well but IE destroyed the data (only in textareas) Do you run the utf8 decoded data through htmlentities()? What does the source code say of the characters outside of the forms and inside the forms? Could you maybe post some chars? Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey guys, i ran into serious trouble when facing the problem to convert data, which was retrieved from a single form in our CMS to match the requirements of multiple charsets. Our CMS uses UTF-8 which worked out quite fine to display the data but caused weired symbols when displayed within a TEXTAREA or INPUT field. Can't you use utf8_decode() to display the utf8 encoded data? So i tried to convert all characters beyound A-Z,0-9 to HTML entities which worked out even better ( i used the following functions to convert the data : function func_ConvertToHTML ( $string ) { $strlen = strlen ( $string ) ; $return = '' ; for ( $str_pos = 0 ; $str_pos $strlen ; $str_pos++ ) { $char = substr ( $string , $str_pos , 1 ); $ascii = ord ( $char ); if ( $ascii 5 == 6 ) { $char2 = substr ( $string , ++$str_pos , 1 ); $ascii2 = ord ($char2); $ascii = 31 ; $ascii2 = 63 ; $ascii2 |= ( ($ascii 3 ) 6 ) ; $ascii = 2 ; $return .= '#x' . str_pad ( dechex( $ascii ) , 2 , '0' , STR_PAD_LEFT ) . str_pad ( dechex( $ascii2 ) , 2 , '0' , STR_PAD_LEFT ) . ';' ; } else { $return .= $char; } } return $return; } But at this point i faced even bigger problems when using this kind of data on JavaScripts or sending the data in an text/plain E-Mail. I tryed to convert the data back but failed as chr() only supports a Charset of 255 Characters ( which most languages don't match eg ru, pl, ch, jp ... ) So my question is if anyone on this list has an idea on how to retrieve the data completely? Some kind of func_ConvertFromHTML() function. Is this what you're looking for?: http://de2.php.net/manual/en/function.html-entity-decode.php Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
[...] Can't you use utf8_decode() to display the utf8 encoded data? [...] The displayed data worked out fine for some languages but others didn't and even simple german chars like äöü won't show up correctly within a textarea. [...] Is this what you're looking for?: http://de2.php.net/manual/en/function.html-entity-decode.php [...] [quote](PHP 4 = 4.3.0, PHP 5)[/quote] This won't work on most servers we're hosting our CMS on :-/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [...] Can't you use utf8_decode() to display the utf8 encoded data? [...] The displayed data worked out fine for some languages but others didn't and even simple german chars like äöü won't show up correctly within a textarea. Hi Red, I'm actually working on a project as well at the moment that uses utf8 data in MySQL. All chars should be OK when output with utf8_decode(). Do the chars only look wrong within textarea or also outside of form elements? [...] Is this what you're looking for?: http://de2.php.net/manual/en/function.html-entity-decode.php [...] [quote](PHP 4 = 4.3.0, PHP 5)[/quote] This won't work on most servers we're hosting our CMS on :-/ Too bad. Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
[] Hi Red, I'm actually working on a project as well at the moment that uses utf8 data in MySQL. All chars should be OK when output with utf8_decode(). Do the chars only look wrong within textarea or also outside of form elements? [] Actually everything ( expect one language ... i guess it was pl ) was displayed fine using utf8_decode but everything within an textarea or our RTE was displayed completly wrong ... either those 1/4... symbols or the good ol '' ... not sure in which kind formated the data was returned :-) -- red -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [] Hi Red, I'm actually working on a project as well at the moment that uses utf8 data in MySQL. All chars should be OK when output with utf8_decode(). Do the chars only look wrong within textarea or also outside of form elements? [] Actually everything ( expect one language ... i guess it was pl ) was displayed fine using utf8_decode but everything within an textarea or our RTE was displayed completly wrong ... either those 1/4... symbols or the good ol '' ... not sure in which kind formated the data was returned :-) Does the data look correct in the database? Have you tried browsing the table with phpMyAdmin? Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
yep, as i said it was displayed correctly everywhere expect in the forms oh i might mention - Mozilla worked well but IE destroyed the data (only in textareas) Torsten Roehr wrote: Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [] Hi Red, I'm actually working on a project as well at the moment that uses utf8 data in MySQL. All chars should be OK when output with utf8_decode(). Do the chars only look wrong within textarea or also outside of form elements? [] Actually everything ( expect one language ... i guess it was pl ) was displayed fine using utf8_decode but everything within an textarea or our RTE was displayed completly wrong ... either those 1/4... symbols or the good ol '' ... not sure in which kind formated the data was returned :-) Does the data look correct in the database? Have you tried browsing the table with phpMyAdmin? Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php