Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rendezvouscp

macrumors 68000
Original poster
Aug 20, 2003
1,526
0
Long Beach, California
Hello. I'm a bit puzzled at the moment with how to make accented characters in URLs work. I'm using .htaccess to pass the information in the URLs to the PHP web app, and that's all working fine. However, for translations I'd like to say something like paginá instead of just page. I already have the system in place to accept translations, so that's not a problem.

I'm fairly familiar with encoding characters with UTF-8 on a web page, but am puzzled when it comes to orchestrating URLs. Does anyone have a good resource to learn about it, or perhaps they know exactly what I need to do?

Thanks in advance.
-Chasen
 
I've been trying to make that work, but I'm unsure what I'm doing wrong. Here's some example code (note: the code is actually spread across files, but here's a simplification):

PHP:
$page = paginá;
echo "	<li class=\"current\"><a href=\"$root/$archives/$page/$id/\" title=\"$Page $id\">$id</a></li>\n";

Code:
RewriteRule ^archivos/paginá/([0-9]+)/?$ index.php?type=archivos&page=$1 [L]

The first is the relevant PHP code, the second the relevant .htaccess code. Everything is being set correctly when
PHP:
$page = page
, since there is nothing to be encoded (and the right information is being brought in from the URL). However, with the accents, I'm being told that the requested URL was not found and the accented a is jibberish (while, if
PHP:
$page = "pagin%E1"
then it says that the requested URL was not found with the a accented as it should be).

So, the whole point is that I do want to be able to pass the URL as something accented because it is much more true to the language. Hopefully, this is possible!

Thanks in advance to anyone that can give me pointers on how to use urlencode properly as well (I've tried
PHP:
echo "	<li class=\"current\"><a href=\"$root/$archives/" . urlencode($page) . "/$id/\"
).
-Chasen
 
Not sure if this will help. read up on it on php.net.

PHP:
\
      //default to UTF-8 change it ISO-8859-1
      //php defaults to ISO-8859-1
      //I think this only works for php 4 and up
       
      $this->charset = "utf-8";   //defaults to utf-8         


                
      iconv_set_encoding("internal_encoding", $this->feed->charset);
      iconv_set_encoding("output_encoding", $this->feed->charset);
      iconv_set_encoding("input_encoding", $this->feed->charset);
 
Alrighty, I'm thoroughly confused about the subject. I'll probably sleep on the issue for the next week and see if I can't figure it out. When I figure out the solution, I'll be sure to post it back here for anyone else to enjoy.
-Chasen
 
rendezvouscp said:
Alrighty, I'm thoroughly confused about the subject. I'll probably sleep on the issue for the next week and see if I can't figure it out. When I figure out the solution, I'll be sure to post it back here for anyone else to enjoy.
-Chasen


it is confusing... all i was saying was, you need to make sure php is going to output in utf. It doesn't default output in utf, so that might be the source of your problems.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.