language problem

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
mwhym

language problem

Post by mwhym »

hello,

I am testing cmsmadesimple for potential use in the future, its really an impressive piece of work :) thanks.

I have run into a problem I cant figure out though, when I use Greek Letters on content pages - the text goes in ok the first time, but if I go to edit the pages the encoding of the Greek characters is all screwed up in the content box afterwards.

This happens to both wysiwyg and plain versions of the editing pages. I am assuming it has to do with the way it reads the page_content entry from the database.

any help would be greatly appreciated

Larry
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

language problem

Post by Ted »

Interesting...

How are you entering the characters? Using a Greek keymap? Just so I know how to duplicate the problem.

I'm assuming it's because most of the Greek characters have html equivilents as opposed to being in Unicode, but I'll need to double check that.

Thanks!
mwhym

yeah

Post by mwhym »

Yes I am using a greek keymap, and yeah I believe you are right that they have html equivalents which is what is happening when you edit. But only happens when I edit not when I insert a new one.

Does the program convert the characters it retrieves from the database to Unicode ?

thanks for listening :) :)
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

language problem

Post by Ted »

Ok, I have a fix for this one. Well, more of a hack, but it does work. Basically, in the config.php file, you will be able to override the encoding of the whole site. For the case of Greek, changing it to "UTF-8" will not only make it work right for the admin, it will also display properly as well. I need to come up with a way to set encoding by a page by page basis, but that's a big undertaking for being so close to another release.

If you're interested in trying 0.7rc2, which will have this fix, please check out the Downloads section of our site later on. Just remember that this is not production ready code, but should be more than adequate for reviewing the software.

Thanks for the bug report!
mwhym

language problem

Post by mwhym »

Great

Will definetly try the 0.7rc2 release.

Thanks :) Looking forward to testing it out more :)
mwhym

language problem

Post by mwhym »

Some Update.

UTF-8 and internet explorer and more than anything Greek are not the easiest to work with. I gave up on the notion even.

I tried version 0.7rc2 - I tried setting it up via the config.php, but still got the same results. Somehow with utf-8 encoding I cant see anything with internet explorer - although I can see it with Firefox, but still it does seem a bit impractical as far as Greek chars are concerned. As the encoding needs to be ISO-8859-7 (or sometimes can use windows-1253), I tried it also, but got the same result as before.

In the end it seems that it all comes back to the htmlentities() function which unfortunately does not support Greek character encoding, so it reverts the encoding to its default ISO-8859-1 - and thus the Greek text gets converted.

I had encountered somethign similar before while reading some forums some time back and after some more searching found the code that I had saved from that dialogue.

Now this is not my code - so I am not claiming any credit for it- unfortunately I cant remember the forum so I cant either give credit to the opriginal author, sorry about that.
You need to add this function and then
you can replace all instances of htmlentities with fix_htmlentities and it seems to work perfectly. So I thought I should share it with you in case it helps anyone.

/**
* HMMMMMMMMMMMMMMMMMMMMM
*
*
*
*/

function fix_htmlentities($string, $param=ENT_QUOTES, $charset="ISO-8859-7")
{
//---------------------------------------------------------------^^^^^^^
// set your own charset!!!
//

// uncomment if htmlentities does not support your charset
return my_htmlentities($string);

return htmlentities($string, $param, $charset);
}

function my_htmlentities($val) {

if ($val == "")
{
return "";
}

$val = str_replace( " ", " ", $val );

//Remove sneaky spaces
// $val = str_replace( chr(0xCA), "", $val );

$val = str_replace( "&" , "&" , $val );
$val = str_replace( "" , "-->" , $val );
$val = preg_replace( "/" , ">" , $val );
$val = str_replace( "" , $val );

$val = preg_replace( "/\\$/" , "$" , $val );

// Uncomment it if you need to remove literal carriage returns
//$val = preg_replace( "/\r/" , "" , $val );

$val = str_replace( "!" , "!" , $val );
$val = str_replace( "'" , "'" , $val );

// Uncomment if you need to convert unicode chars
// $val = preg_replace("/&#([0-9]+);/s", "&#\1;", $val );

// Strip slashes if not already done so.

if ( get_magic_quotes_gpc() )
{
$val = stripslashes($val);
}

// Swop user inputted backslashes (this caused an error so
// I commented it)

// $val = preg_replace( "/\(?!&#|?#)/", "\", $val );

return $val;
}
//------------------------



Hope it helps

Cheers :)
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

language problem

Post by Ted »

Ah, I didn't realize that it was ISO-8859-7. On my Mac, Greek input is Unicode.

I'll take a look at that code. There MIGHT be a way that I can automate the process of switching to the function you gave me if using a character set that isn't "supported" by PHP. Still it seems weird that it would default to 8859-1 and not UTF-8. Seems very backwards to me.

Anyway, thanks. I'll look into it this weekend.
peca

language problem

Post by peca »

I have the same problem as mwhym, but with czech language using iso-8859-2 encoding
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

language problem

Post by Ted »

I have fixes planned for 0.7.1 for this issue.

1. Template will be able to have an encoding set on it and all pages using that template will automatically use that encoding.

2. I'm going to use that code that he posted above if the html_entities fails. I didn't have time to implement it before 0.7 went out.

I'm planning 0.7.1 for the end of this week/early next week.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

language problem

Post by Ted »

Is there anyway either (or both) can test code from svn? I REALLY think I have the problems fixed. You can either setting a default encoding in the config.php, or overriding the encoding on the template. It SEEMS to work with my testing, but it would really help if it could be tested in a real-world environment.

Let me know if you need help getting code out of svn.

Thanks!
mwhym

language problem

Post by mwhym »

Sorry for the delay but had some family probs which have kept me away from anything fun.

I will sure like to help and try it out, but whats the svn ?
Sorry for my ignorance :(
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

language problem

Post by Ted »

You can use the new daily svn snapshot instead of checking it out from svn. The URL is http://cmsmadesimple.org/cms-daily.tar.gz.

Thanks!
piratos

language problem

Post by piratos »

Hi - that is what you need.

http://forum.cmsmadesimple.org/viewtopic.php?t=182

Change the charcodes to what you want.
Locked

Return to “[locked] Installation, Setup and Upgrade”