Re: Special characters from the model and str_replace()

2006-08-04 Thread Bert Van den Brande

Hmm ok tnx, I'll retry the Eclipse problem tonight ...

On 8/4/06, meek [EMAIL PROTECTED] wrote:

 These are the things I do to make sure I can work consistently with
 UTF-8.

 1) Make sure that the MySQL server and your database and all tables
 within it are configured to store and output strings as UTF-8.

 2) Make sure that the MySQL connection from CAKE is configured for
 UTF-8 encoding. I do this in an overriden constructor in
 app/app_model.php:

 function __construct()
 {
 parent::__construct();
 $this-execute(SET NAMES 'UTF8');
  }

 - I got this from an earlier discussion in this group I think. It made
 the real difference for me.

 3) Set the encoding for all your views as UTF-8 using the PHP header
 command. At the moment I do this right at the top of my layouts - it
 needs to go in somewhere before anything else is rendered:

 ?php header(Content-type: text/html;charset=UTF-8); ?


 4) Set the charset in HTML using the HTMLHelper although I don't think
 this is so important:

 ?php echo $html-charset('utf-8')?

 5) Make sure all your .php and .thtml files are UTF-8 encoded. Eclipse
 and JEdit both do this fine and consistently.

 - str_replace seems to work for me if I do all that (in PHP4) - I don't
 use the multibyte functions.


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-04 Thread [EMAIL PROTECTED]

I've had frustrating encoding problems in PHP before, some still
persisting on my site because  I could not fully resolve them. Your
post here is extremely helpful! I was not aware of all those setup
options.

The encoding problems in PHP have, of course, been widely excoriated.
From your post it seems that adequate documentation could make a big
difference.

Could you try posting that on the PHP web site?

Thanks again.

meek wrote:
 These are the things I do to make sure I can work consistently with
 UTF-8.

 1) Make sure that the MySQL server and your database and all tables
 within it are configured to store and output strings as UTF-8.

 2) Make sure that the MySQL connection from CAKE is configured for
 UTF-8 encoding. I do this in an overriden constructor in
 app/app_model.php:

 function __construct()
 {
 parent::__construct();
 $this-execute(SET NAMES 'UTF8');
  }

 - I got this from an earlier discussion in this group I think. It made
 the real difference for me.

 3) Set the encoding for all your views as UTF-8 using the PHP header
 command. At the moment I do this right at the top of my layouts - it
 needs to go in somewhere before anything else is rendered:

 ?php header(Content-type: text/html;charset=UTF-8); ?


 4) Set the charset in HTML using the HTMLHelper although I don't think
 this is so important:

 ?php echo $html-charset('utf-8')?

 5) Make sure all your .php and .thtml files are UTF-8 encoded. Eclipse
 and JEdit both do this fine and consistently.

 - str_replace seems to work for me if I do all that (in PHP4) - I don't
 use the multibyte functions.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-04 Thread anarchitect

Now the phenomenon gets clearer, i am still in clueless state, though.

Getting data in a regular fashion from models to the views via the
$this-set('var', $this-Post-findAll(null,null,'Post.created DESC'));
seems to work.

But if i want to display stuff within a view from other models encoding
seems to get treated differently. The two cases that i am stumbling
about right now are components/elements and associated models - in my
case a tag model via hasAndBelongsToMany. Umlaut-characters are shown
screwed up.

Does anybody has any insight where the difference might lie? Thanks
again.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-04 Thread anarchitect

Okay. Finally, i got it. My speculation from the last post are way off.
The problems occurred when i used html-link() without disabling
html-encoding/escaping. Adding false as the 5th parameter everytime
solves all my special character problems. Thanks for you guys' patience.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-04 Thread Samuel DeVore
So now I have to admint I haven't been reading this thread at all, and I have no experience with this particular problem. But when I was helping someone track down some problems with jpGraph and cake. we were having problems with encoding of the resulting image. It turned out that a couple of the files had BOM settings that were differenet then what we were trying to output and it was getting cakephp/ php and apache all confused. After stripping BOMs from all the files we had better luck
Sam DOn 8/4/06, anarchitect [EMAIL PROTECTED] wrote:
Now the phenomenon gets clearer, i am still in clueless state, though.Getting data in a regular fashion from models to the views via the$this-set('var', $this-Post-findAll(null,null,'Post.created
 DESC'));seems to work.But if i want to display stuff within a view from other models encodingseems to get treated differently. The two cases that i am stumblingabout right now are components/elements and associated models - in my
case a tag model via hasAndBelongsToMany. Umlaut-characters are shownscrewed up.Does anybody has any insight where the difference might lie? Thanksagain.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---


Re: Special characters from the model and str_replace()

2006-08-04 Thread anarchitect

I have read about your bundle, but i havent tested it, yet .. wasnt it
requiring some software repository check out process ;)

Do you have a link or someting? Thanks


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-04 Thread Chris Hartjes

Where can you get the CakePHP bundle?  I'm a TextMate user too...

On 8/4/06, Samuel DeVore [EMAIL PROTECTED] wrote:
 TextMate does rock, are you using the CakePHP bundle?  It's written by some
 old fart but it is pretty cool

 Sam D

 ps I am the old fart ;)


 On 8/4/06, anarchitect [EMAIL PROTECTED] wrote:
 
  I have read about that also, but my current editor - TextMate -
  doesnt do that kind of thing ;)
 
  I was just not aware that Cake was trying to be friendly - creating
  html entities on the fly - while this seems to cause problems in a
  UTF-8 setting. After all it is not necessary.
 
 
 
 
   
 



-- 
Chris Hartjes

The greatest inefficiencies come from solving problems you will never have.
-- Rasmus Lerdorf

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-04 Thread anarchitect

Great. Thanks a lot.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Special characters from the model and str_replace()

2006-08-03 Thread anarchitect

Good afternoon everbody, i have some troubles turning special
characters into clean characters to use for a slug (read: clean url
string). I am running a str_replace() over the data that i receive from
the model, yet it seams that special characters (such as öäü...) are
encoded in something special, so that str_replace() won't work.

$title = $entry['Post']['title'];
$title = strtolower($title);
$umlaute = array (ü, ö, ä, ß);
$replace  = array (ue, oe, ae, ss);
$title = str_replace($umlaute, $replace, $title);
$title = preg_replace(/\W/, , $title);
$entry['Post']['slug'] = $title;

Any hints how i could turn de-code them from the model?

Thanks for any help


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-03 Thread anarchitect

@John: Yes, i can and it works technically, as the created slug works
as expected. Yet esthetically this is not that nice:

posts/view/%DCberschrift

In German - and i think this counts for other languages - there are
replacements for  special characters. As indicated in the code above.
Therefore it would be nice if i actually could access (find and
replace) the special characters that are entered in the form.

@Chris: could you be a bit more specific. I guess i have no clue what
multibyte string manipulation means.

Does anybody know how data is encoded before saved via the model in the
database and how this could be decoded to access as described above?
Thanks again.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Special characters from the model and str_replace()

2006-08-03 Thread anarchitect

Okay i got it working now. The result coming from the model/database is
encoded as something different then UTF-8. Therefore utf8_encode() will
do the job.

The thing is i am a bit confused now. The pages rendered by cake are
not UTF-8 but seem to be something like ISO-8859-1. I would like to go
all UTF-8. How can i do this? Is there a setting to fetch the data from
the model in UTF-8? Is there anything to read and learn in regard to
encoding and cake?

Thanks guys for pointing me in the right direction.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---