Funny Characters - Upload Chinese characters using PHP GET to MySQL

So, there is a textfield. Input will be inserted to mysql db using PHP script.

It works fine with English. But if the input is in Chinese, it displayed as funny charaters in mysql.

Upload URL I’m using is like this

url = “http:/xxx/lib/borrow.php?bookID=” … idx…"&borrower="…nameField.text…"&contact="…contactField.text

  1. it works using just a string variable with Chinese characters.

local test = “我”

url = “http:/xxx/lib/borrow.php?bookID=” … idx…"&borrower="…test…"&contact="…test

  1. if I just execute this url in a browser, it also works.

url = "http:/xxx/lib/borrow.php?bookID=11&borrower=我&contact=我

Help help please.

Chinese characters are done using UTF-8 multi-byte characters.  URL’s cannot handle processing these as they are ASCII only and even at that they are symbol challenged.  URL data like that needs to be URL encoded before you transmit it to a web server.  Then your PHP script would need to be UTF-8 aware and the MySQL database tables have to handle UTF-8 encoding.

When you enter the characters in the URL of the browser, the browser does the URL encoding for you.  When you do it through software, you have to do the URL encoding yourself.

Rob

Thank you Rob!!! That’s it. URLencoding.

I use mime.b64 to encode the textfield.text before passing it to the URL. Works perfect.

Anyone got the same issue can refer to http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/

UPDATE:

actually, mime.b64 can’t encode all chinese characters. I fiind url.escape() solves the problem.

Chinese characters are done using UTF-8 multi-byte characters.  URL’s cannot handle processing these as they are ASCII only and even at that they are symbol challenged.  URL data like that needs to be URL encoded before you transmit it to a web server.  Then your PHP script would need to be UTF-8 aware and the MySQL database tables have to handle UTF-8 encoding.

When you enter the characters in the URL of the browser, the browser does the URL encoding for you.  When you do it through software, you have to do the URL encoding yourself.

Rob

Thank you Rob!!! That’s it. URLencoding.

I use mime.b64 to encode the textfield.text before passing it to the URL. Works perfect.

Anyone got the same issue can refer to http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/

UPDATE:

actually, mime.b64 can’t encode all chinese characters. I fiind url.escape() solves the problem.