2

In cakephp, I would like to use an url parameter which might contain some special chars like é or è.

When I print $this->params['url'] for this url for example: http://dev.family/registration?fname=kr%E9s

I get: Array ( [url] => registration [fname] => kr�s )

So the é becomes a question mark.

I tried urldecode, but I doesn't help. I guess this has something to do with UTF-8 encoding, but I don't know where to search.

Any suggestions?

Krikke

2
  • What character encoding are you using? Commented Aug 25, 2011 at 21:47
  • It should be UTF-8, but I guess it is not.. How can I make sure it's UTF-8? Do I need to change something in my config? Commented Aug 26, 2011 at 7:16

2 Answers 2

1

Try htmlentities() function.

Sign up to request clarification or add additional context in comments.

Comments

1

I just fixed the problem thanks to B7ackAnge7z.

The htmlentities function worked, but translates krés to krés. This fixes the problem with the question mark.

But.. I want to use this value to pre-fill a form input. So the input would contain krés, which is not what I intented.

So I prefill it with this value now:

html_entity_decode(htmlentities($this->params['url']['fname']), ENT_COMPAT, 'UTF-8')

-> convert the value with htmlentities and then decode it again to UTF-8. Somewhat a dirty fix...

I guess cake doesn't decode URL parameters to UTF-8 default or maybe I should worry about an encoding problem somewhere in my cake project?

Thx!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.