galdikas
galdikas

Reputation: 1669

Avoid/fix codeigniter from encoding UTF-8 characters?

Lets take this url:

localhost/pradzia/narsyti_krovinius/marsruto_pabaiga/Belebėjus

Using the URI class in codeigniter in grab the last segment, using which I want to make a database lookup. However it was failing for me. And couldnt figure out why for ages. But then I tried to output it, and what I got was: Beleb%C4%97jus instead of Belebėjus. So what I want to is either a way to exclude that particular segment from any filtering by codeigniter, or some function that would give me the original string?

I tried to run it through utf8_encode() but it did not work.

So in short: A: Anyway to exclude a particular instance of uri->segment(n) from whatever filtering codeigniter does?

Or if that not possible:

B: How would I convert the above (or any other string with UTF chars) back to original form?

Upvotes: 0

Views: 434

Answers (1)

Aurel
Aurel

Reputation: 3740

urldecode( $this->uri->segment(n) );

Your html page or http header have to be set with UTF-8 when you display the value.

eg: <meta charset="utf-8">

Upvotes: 3

Related Questions