Notifications
Clear all

Username encoding

6 Posts
3 Users
0 Likes
1,165 Views
(@gecko64)
Posts: 82
Estimable Member
Topic starter
 

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

 
Posted : 06/05/2017 8:20 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

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).

 

Schermata-2017-05-06-alle-19.12.04.pngSchermata-2017-05-06-alle-19.12.19.png

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 06/05/2017 9:16 pm
(@tommih)
Posts: 44
Trusted Member
 

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?

 
Posted : 23/05/2017 7:06 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

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

 
Posted : 23/05/2017 9:18 pm
(@tommih)
Posts: 44
Trusted Member
 

Debug.Log prints out the username as "♡Luna♡", and I even tried passing "♡Luna♡" directly to Authenticate. The request URL becomes in both cases:

Sending: http://wolfquest.org/combu/users.php?action=login&Username=%e2%99%a1Luna%e2%99%a1&Password=051a9911de7b5bbc610b76f4eda834a0&sig_time=636322590475045780&sig_crc=7dad8ba99d1880ea5676b7e2ed8f24dc8a6287aa

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?

 
Posted : 05/06/2017 1:34 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

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

 
Posted : 05/06/2017 9:53 pm
Share: