Closed goodman-capu closed 7 years ago
I guess I will use the native MySQL C API functions: mysql_real_escape_string and/or mysql_real_escape_string_quote.
Hi there,
Check the latest release. I added a public method -escapedUsingEncoding
. Although, I am still in progress due to lack of the time. The next step is applying the method to a query.
There are problem with this function: Not every character's length is 2.
For example, if you run this code:
NSLog(@"%@", [@"好" escapedUsingEncoding:NSUTF8StringEncoding]);
or this:
NSLog(@"%@", [@"😁" escapedUsingEncoding:NSUTF8StringEncoding]);
The app would crash, for some Chinese characters' length is 3, and for some Emoji it's 4.
You passed an incorrect enum type. Due to different char sets support I had to define own type CharsetEncoding
. Please, try CharsetEncodingUTF8
.
Opps, my bad. It worked fine.
Well, public method added. The developer is responsible to call -escapedUsingEncoding
if needed (like in MySQL C API mysql_real_escape_string()
). The issue is closed.
The building of query string lacks escaping of special characters. I suggest adding a public function like this and apply it to
NSString (SQLQueries)
functions.