views:

551

answers:

2

Hi!

I want to route url through Zend route regex with Swedish character and here is my regex in xml configuration:

..... ([a-z\-å|ä|ö]+) .....

Still, the route doesn't behave as I expect. It doesn't redirect when the link contains å, ä, or ö

I have tried to change to [a-zåäö\-]+ but it also gives the same result..

anyone can help? Thank you so much in advance! :)

A: 

I think the browser would encode those characters and not sure Zend Framework decode it before passing it to the route engine, can you try a regexp with the % equivalent of those characters ?

RageZ
A: 

I'm not sure about Zend route, but when using, for instance, preg_match, you may want to go for something like

preg_match('/[a-zåä]/u',$url);

(note the u for unicode). Another possibility is that your data is %-escaped.

And I'm not sure what [a-z-å|ä|ö] supposed to mean…

Michael Krelin - hacker
sorry... I didn't type it correctly :PI want a regex that recognize words such as:Åsa-Larsson or Peter-Renström
ah, I'd say `[a-zåäö-] or something like that. Well, still - check what does your data look like and whether your regex is willing to handle unicode.
Michael Krelin - hacker
I kinda lost you, but my data from MySQL can save Åsa as a data, and I can see correctly through my browser.And about my regex willing to handle unicode.. how would I know that? :PI tried to use [a-zåäö-] as you said but.. it still doesn't match å, ä, ö chars
By the data I mean the data your regex is matched against. The URL, or whatever. It may come in %-encoded form. About the regex - I gave you an example of preg_match call, which, in order to work fine with unicode needs this `/u` thingie. I have no idea how you pass your regex to Zend, but if, by chance, you pass it in `//` you may want to add `u` there. Again, I have no idea about Zend ;-)
Michael Krelin - hacker
dude.. on the xml file, I put the regex like this:[a-z-%C3%A4%C3%A5%C3%B6]+and it works... but!!! the next thing is.. when I fetch the url as params.. it goes wild also.. with %-encoded... how can I transform it? for example, C3%B6 --> öusing preg_replace right?Dude.. really.. I appreciate your kindness... when you come to Stockholm, I'll treat you.. hahahaha... peace bro..
solve it.. alright..!!
Now I don't follow you, but as long as it's working... ;)
Michael Krelin - hacker