Page 1 of 1

php equivalent of percent escape + UTF8

Posted: Sun Aug 02, 2009 11:40 pm
by bsharp42
Hello,

I have an iphone app which uses a website of mine.
In iphone I convert a search query into


[search_Query.text stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]

Following is the declaration of stringByAdding.....
Returns a representation of the receiver using a given encoding to determine the percent escapes necessary to convert the receiver into a legal URL string.

- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
Parameters

encoding

The encoding to use for the returned string.

Return Value

A representation of the receiver using encoding to determine the percent escapes necessary to convert the receiver into a legal URL string. Returns nil if encoding cannot encode a particular character
and the NSUTF8stringEncdoing is the Mac/obj-c equivalent of UTF8stringencoding I believe.

Anyway, my question is, is there a way to convert a php string into a string with Percent Escapes using UTF8 encoding

Re: php equivalent of percent escape + UTF8

Posted: Mon Aug 03, 2009 2:40 am
by cpetercarter
Use urlencode(). Have a look at http://uk3.php.net/urlencode, especially the top comment.