Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2010, 03:28 PM   PM User | #1
alexpk
New Coder

 
Join Date: Jul 2009
Posts: 45
Thanks: 23
Thanked 0 Times in 0 Posts
alexpk is an unknown quantity at this point
Convert chars in url (%E0%EB%E5%) to cyrillic

Hello how can I convert from url a %E0%EB%E5% to display in cyrillic: але

Sample with Google
Quote:
http://www.google.bg/search?hl=bg&so...007&bih=576&q=%E0%EB%E5&aq=f&aqi=g10&aql=&oq=&gs_rfai=
alexpk is offline   Reply With Quote
Old 12-18-2010, 04:20 PM   PM User | #2
poyzn
Regular Coder

 
poyzn's Avatar
 
Join Date: Nov 2010
Posts: 265
Thanks: 2
Thanked 61 Times in 61 Posts
poyzn is on a distinguished road
try this with the string
PHP Code:
echo urldecode('%E0%EB%E5'); 
or with the whole url
PHP Code:
echo urldecode('http://www.google.bg/search?hl=bg&source=hp&biw=1007&bih=576&q=%E0%EB%E5&aq=f&aqi=g10&aql=&oq=&gs_rfai='); 
__________________
Ushousebuilders.com
poyzn is offline   Reply With Quote
Users who have thanked poyzn for this post:
alexpk (12-19-2010)
Old 12-18-2010, 04:41 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
On a side note, if this is coming from your own querystring, you should not need to urldecode your own get/request data. The same applies for a form as well so long as it was not entered in encoded data.
Beyond this, you may need to send the proper content-type headers to change the charset in use.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
alexpk (12-19-2010)
Old 12-18-2010, 05:14 PM   PM User | #4
alexpk
New Coder

 
Join Date: Jul 2009
Posts: 45
Thanks: 23
Thanked 0 Times in 0 Posts
alexpk is an unknown quantity at this point
Actually I want to control the text via url, not via form.I know that if I use it with form, it works.

The urldecode doesn't work.

When I use the form I get - %D0%B0%D0%BB%D0%B5 and that works, but when I just type in the url I get %E0%EB%E5 and that is wrong. (this is one some text)
alexpk is offline   Reply With Quote
Old 12-18-2010, 06:24 PM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
By URL you mean your URL correct? Not evaluating an external one?
According to the API, both REQUEST and GET are automatically decoded when interpreting the querystring. It also indicates manually decoding the already decoded data is dangerous: http://php.ca/manual/en/function.urldecode.php

When you are creating the querystring to pass, you must encode this yourself.

When you type in the actual %XX strings into a urldecode, which one provides the proper results the first or the second? I would assume the first which would indicate that the actual typing into the url is your bottleneck, and not the processing itself (perhaps the browser isn't interpreting the characterset properly).

I can't view either of these ones and I'm not installing new language sets just to check. PHP has always been a pain with multibyte charsets too, hopefully the native utf8 in PHP6 will help this.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
alexpk (12-19-2010)
Old 12-18-2010, 08:21 PM   PM User | #6
poyzn
Regular Coder

 
poyzn's Avatar
 
Join Date: Nov 2010
Posts: 265
Thanks: 2
Thanked 61 Times in 61 Posts
poyzn is on a distinguished road
Quote:
Originally Posted by Fou-Lu View Post
I can't view either of these ones and I'm not installing new language sets just to check. PHP has always been a pain with multibyte charsets too, hopefully the native utf8 in PHP6 will help this.
There is no problem with utf8 in php5. It works fine even in ajax.
__________________
Ushousebuilders.com

Last edited by poyzn; 12-18-2010 at 08:25 PM..
poyzn is offline   Reply With Quote
Users who have thanked poyzn for this post:
alexpk (12-19-2010)
Old 12-18-2010, 10:45 PM   PM User | #7
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
I didn't say it was a problem, I said it was a pain. PHP is not native to multibyte charsets; that feature will (supposedly) be added in PHP6.
To use multibyte you'll need to ensure that mb_string has been loaded within PHP, and to chain it to standard string manipulation functions (such as substr and strlen for examples), the ini must be set to include the mbstring.func_overload to override the original functions. This ONLY applies to string manipulations, input variable handling should not be impacted if only in and out are performed without any additional work. It is highly probable that PHP will not detect the charset though, so you will likely need to send a content-type header in order to pump the correct character sets.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
alexpk (12-19-2010)
Old 12-19-2010, 09:55 AM   PM User | #8
alexpk
New Coder

 
Join Date: Jul 2009
Posts: 45
Thanks: 23
Thanked 0 Times in 0 Posts
alexpk is an unknown quantity at this point
I collected all the characters after moving them from form and then used them with preg_replace to make them work.Thanks for the replies.
alexpk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:25 PM.


Advertisement
Log in to turn off these ads.