Results 1 to 6 of 6

Thread: [CoD2] [MySQL] [libcod] Special characters

  1. #1
    Private
    Join Date
    Feb 2013
    Location
    Poland
    Posts
    32
    Thanks
    33
    Thanked 27 Times in 8 Posts

    [CoD2] [MySQL] [libcod] Special characters

    Hello,

    I've got a problem with players' names on server. I want to store them in MySQL DB. Connection works nice. I save it without problems. But I can't read/select including special chatacters.

    I have written debug to check, whats wrong.

    Normally I got this:
    Code:
    guid=123456 score=0 name=Unnamed Player
    But when player has special characters in his name:
    Code:
                   ^33×YankeS×^2Ž
    PHP reads his name as:
    Code:
     
    ^^00Gumowy#^2Š››^^33×YankeS×^2Ž
    The real nickname is:
    Click image for larger version. 

Name:	qie04r.jpg 
Views:	110 
Size:	5.5 KB 
ID:	540

    MySQL query:
    PHP Code:
    SELECT `guid`, `score`, `last_nickFROM players WHERE `guid`='xxxxxx' 
    How can I read special characters from MySQL?

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Insert them using
    Code:
    newstring = mysql_real_escape_string(mysql, oldstring)

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    BlancO (20th November 2013)

  4. #3
    Private
    Join Date
    Feb 2013
    Location
    Poland
    Posts
    32
    Thanks
    33
    Thanked 27 Times in 8 Posts
    I'm not quite sure if I am doing it right:

    PHP Code:
        sql "UPDATE players SET nick='" mysql_real_escape_string(level.mysqlself.name) + "' WHERE guid='" self getGuid() + "'"

  5. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Had same issues, dunno anymore what I did exactly to solve it though. Try something like:


    PHP Code:
    $strQuery "SET character_set_results = 'utf8', 
      character_set_client = 'utf8', 
      character_set_connection = 'utf8', 
      character_set_database = 'utf8', 
      character_set_server = 'utf8'"
    ;
    mysql_query($strQuery); 
    PHP Code:
        while ($row mysql_fetch_assoc($query))
        {
            
    $hostname utf8_decode($row["hostname"]);

            echo 
    $hostname;
        } 
    timescale 0.01

  6. #5
    Private
    Join Date
    Feb 2013
    Location
    Poland
    Posts
    32
    Thanks
    33
    Thanked 27 Times in 8 Posts
    How is it possible in .gsc files?

  7. #6
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    ATM there is no such function, but you could either add that function yourself or test first with getAscii() of libcod:

    PHP Code:
    getAscii(str) { return closer(902str); } 
    Example from ClientCommand:
    PHP Code:

    fixChatArgs
    (args)
    {
        if (
    isDefined(args[1])) { // engine is adding identifier infront of the chat message
            
    if (std\utils::getAscii(args[1][0]) >= 20 && std\utils::getAscii(args[1][0]) <= 22) {
                
    //std\io::print("delete bad ascii code: " + std\utils::getAscii(args[1][0]) + "\n");
                
    args[1] = getSubStr(args[1], 1);
                
                
    newArgs strTok(args[1], " ");
                for (
    i=0i<newArgs.sizei++)
                    
    args[1+i] = newArgs[i];
            }
        }
        return 
    args;

    Then step over any char, print the ascii-numbers, check whats wrong, search for solution.
    timescale 0.01

  8. The Following User Says Thank You to kung foo man For This Useful Post:

    BlancO (22nd November 2013)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •