Austinb / GameQ

A PHP Gameserver Status Query Library
https://austinb.github.io/GameQ/
GNU Lesser General Public License v3.0
403 stars 135 forks source link

SAMP problem #477

Closed MrFallen closed 5 years ago

MrFallen commented 5 years ago

SAMP does not work with Russian characters in the server name. :(

rostov114 commented 5 years ago

Please provide examples of servers.

rostov114 commented 5 years ago

The problem is that GameQ runs UTF-8 by default. Russian SAMP servers return data encoded in Windows-1251. You can apply a filter that will detect data encoded in Windows-1251 and reencoding them to UTP-8. But this is a shit decision.

Austinb commented 5 years ago

SAMP does not force the character encoding to UTF-8. It is probably coming back from the server with that character encoding.

Please send over a server with the issue so we can test. Would like to make sure the data coming back is correct and that you just need to convert the encoding on the results.

rostov114 commented 5 years ago

@Austinb 46.174.48.144:8904

Austinb commented 5 years ago

So after looking at this the host name is coming back with hex characters which should be converted into utf8 to make it the same as the rest of the protocols. I will make the changes to convert them from hex to utf8 at which point you can use mb_convert_encoding() to convert it from utf8 to Windows-1251 which will give you the proper Russian characters.

For that server the raw response in the results array should be something like Village RolePlay | Àêöèÿ õ2

Example converting to proper encoding to show the proper Russian characters - mb_convert_encoding($server_name, "Windows-1251", "utf-8")

gaisindanil commented 8 months ago

So after looking at this the host name is coming back with hex characters which should be converted into utf8 to make it the same as the rest of the protocols. I will make the changes to convert them from hex to utf8 at which point you can use mb_convert_encoding() to convert it from utf8 to Windows-1251 which will give you the proper Russian characters.

For that server the raw response in the results array should be something like Village RolePlay | Àêöèÿ õ2

Example converting to proper encoding to show the proper Russian characters - mb_convert_encoding($server_name, "Windows-1251", "utf-8")

the problem is still relevant with Russian characters

aleks78888 commented 7 months ago

У меня получилось исправить кодировку следующим образом:

header('Content-Type:text/html; charset=utf-8'); $server_name = iconv('utf-8//IGNORE', 'cp1252//IGNORE', $server_name); $server_name = iconv('cp1251//IGNORE', 'utf-8//IGNORE', $server_name);