Some of our players create usernames with special characters -- for example, ♡Luna♡. We've discovered that there must be some type of encoding done on the combu side before storing the userid in the database, since there is no user in the combu table with the username ♡Luna♡, but there are the following two:
♡Luna♡
☆Luna☆
Can you tell us what type of conversion is done so we can incorporate it into a related tool that we're developing?
thanks
Dave
I'm able to register and login with username ♡Luna♡ correctly in the demo scene, and it's correctly saved in MySql (see the screenshots).
You may need to debug what is passed to Authenticate method (I suppose the table is already set to UTF8 as collation).
FRANCESCO CROCETTI @ SKARED CREATIONS
So do I understand it correctly? Everything is supposed to be encoded with UTF8, and you're asking if the table on our server is encoded with that?
Yes, theoretically the JSON should automatically convert the UTF8 symbols into something like "uXXXX" in the request data, did you try to see what is passed to Authenticate with Debug.Log?
Also you could try to register a new user with a similar name (with symbols) and see what is saved into the database, if the encoding is working fine then you should see the correct symbols in the database as it's displayed in my second screenshot above (it's phpMyAdmin on a web browser).
I tried also to pass it directly in a script and it worked fine as well:
IEnumerator Start () { while (!CombuManager.isInitialized) yield return null; string username = "♡Luna♡"; string password = "aa"; if (!CombuManager.localUser.authenticated) { CombuManager.platform.Authenticate (username, password, (bool loginSuccess, string loginError) => { Debug.Log("Login: " + loginSuccess + " -- " + loginError); }); } }
FRANCESCO CROCETTI @ SKARED CREATIONS
Debug.Log prints out the username as "♡Luna♡", and I even tried passing "♡Luna♡" directly to Authenticate. The request URL becomes in both cases:
Is this how it's supposed to work? If you pass this URL (or similar in terms of the "♡Luna♡" part anyway) to your working setup, does it get read correctly (as "♡Luna♡") on your server's end? This information should help us determine if the problem is on the Unity end or the server end.
Edit: According to this website, the encoding should be correct (e2 99 a1 =♡): http://www.utf8-chartable.de/unicode-utf8-table.pl?start=9728&names=-
So something must be amiss on the server's end. Or is the server expecting some other kind of encoding? What does the URL look like when you test it fro your demo scene?
Yes, that's the URL that I see on login by activating the debug log, and the server is returning this to me:
TEXT: {"success":true,"message":"{"Id":"3","Username":"\u2661Luna\u2661","GUID":"593594abcdbc10.25240020","Email":"","LastSeen":"2017-06-05 17:28:11","CustomData":[],"Platforms":[]}","errors":[]}
Anyway I'm pretty sure it has something to do with your MySql default character set, try to replace the function _selectDatabase() in /lib/Database.php with this and retry to register (and then login) a new account with that "heart" symbol and check it back on your database:
private function _selectDatabase() { mysqli_select_db($this->_connection, $this->_dbName); mysqli_set_charset($this->_connection, "utf8"); }
PS: I hope you have at least the latest version of Database, with "mysqli_*" functions having replaced "mysql_*". Though I'm not sure what happens to the current registered accounts which have UTF8 symbols in username, but they're currently not able to login then probably there's no issue.
FRANCESCO CROCETTI @ SKARED CREATIONS