This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

How to parse cyrillic symbols from rcon?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 03:19.


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