Raised This Month: $12 Target: $400
 3% 

How to parse cyrillic symbols from rcon?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FeTiD
Junior Member
Join Date: Feb 2009
Old 01-30-2016 , 04:49   How to parse cyrillic symbols from rcon?
Reply With Quote #1

I send, for example, amx_mycommand "Новый игрок example строка here" via rcon in UTF-8.
On the server side (Linux HLDS cstrike 6153, amxx 1.82, meta 1.20) message in console appears normally as is. Storing it in file by read_args() creates UTF-8 text file with original comand correctly.
This is the part plugin's code:
Code:
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_srvcmd("amx_mycommand",   "amx_mycommand",   0)

}
public amx_mycommand()
{
    new argument[192]
    static last_used_argument[192]
    read_args(argument, 191)
    if (equal(argument, last_used_argument)) {
        console_print(0, "Command repeated!")
        return PLUGIN_HANDLED_MAIN
    }
    copy(last_used_argument, strlen(argument), argument)
    new pos = contain(argument, "Новый")
    console_print(0, "pos= %d", pos)
    if (pos != -1) {
        //This part of code never executes cuz pos always -1
    }
    return PLUGIN_CONTINUE
        
}
I save .sma file in UTF-8 and compile.
As u see contain() can not work with cyrillic, so I added little construction to check ASCII number of each symbol below console_print(0, "pos= %d", pos) section:
Code:
new k
    while(argument[k] != 32) //parsing ASCII characters for the first word (until 'space' is found)
    {
        console_print(0, "Symbol %d is %c/%d", k, argument[k], argument[k])
        k++
    }
Latin symbols has correct ASCII codes, but here is the listing for string from example before:
Code:
L 01/29/2016 - 17:28:30: Rcon: "rcon 2004634538 "pass" amx_mycommand "Новый игрок example строка here"
pos= -1
Symbol 0 is *********/-48
Symbol 1 is *********/-99
Symbol 2 is *********/-48
Symbol 3 is *********/-66
Symbol 4 is *********/-48
Symbol 5 is *********/-78
Symbol 6 is *********/-47
Symbol 7 is *********/-117
Symbol 8 is *********/-48
Symbol 9 is *********/-71
As u see len of first word not equal with original one, and ascii codes all negative for cyrillic symbols and have sometimes the same values for different letters.
So i tried to add this test constriction:
Code:
new my_awesome_string_array_dunno_what_cp_is_it[] =
{ -48, -99, -48, -66, -48, -78, -47, -117, -48, -71 }
contain(argument, my_awesome_string_array_dunno_what_cp_is_it)
not work!

Any ideas?

btw ********* in listing is one symbol, but forum writes is like this

Last edited by FeTiD; 01-30-2016 at 04:53.
FeTiD is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-30-2016 , 05:22   Re: How to parse cyrillic symbols from rcon?
Reply With Quote #2

Yes, it's expected. There is a better unicode support in 1.8.3-dev. It has been fixed there.

References: reported at bug 5945, fixed in #23.
__________________

Last edited by Arkshine; 01-30-2016 at 05:23.
Arkshine is offline
nokidding
New Member
Join Date: Apr 2024
Old 05-16-2024 , 08:03   Re: How to parse cyrillic symbols from rcon?
Reply With Quote #3

Quote:
Originally Posted by FeTiD View Post
I have had a lot of fun betting online on my favourite sports in Nigeria on this site - 22bet . Here you will have a wide door to betting in Nigeria, and you will be able to feel what it is like to make online sports betting on a quality site! So I advise you to try this site and not to lose sight of it.
nice ty
nokidding is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode