Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved MySQL special characters

Comments in 'Plugin Development' started by Timmpann, Jan 10, 2016.

  1. Timmpann
    Offline

    Timmpann New Member

    Joined:
    Feb 5, 2015
    Posts:
    24
    Minecraft User:
    Timmpann
    I'm making a plugin that broadcasts strings from a MySQL database, but when I'm using a special character like "å, ä, ö" it doesn't show up. In the console the character changes into "?" and on the client the message is being cut of where the character should be.

    The database has UTF-8 encoding, so it's supposed to work. How can I fix it?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Your database may be encoded in UTF-8, but are you sure you sent the data in UTF-8?
    Timmpann likes this.
  3. Timmpann
    Offline

    Timmpann New Member

    Joined:
    Feb 5, 2015
    Posts:
    24
    Minecraft User:
    Timmpann
    Why the hell does it not send the data in UTF-8 when it's encoded that way? That's stupid. xD

    It was fixed by setting the charset: http://php.net/manual/en/mysqli.set-charset.php
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Even more stupid: mysqli_result->fetch_***() returns values in strings while it is an INT on the database. (Probably limitation of the MySQL protocol)
    I spent a whole week to fix bugs caused by that (and failed to release server on Christmas :()
    Timmpann and Legoboy0215 like this.
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    var_dump() is your friend.
    Vaivez66 likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I had code that detects if a variable is a string, wrap it with "
    And then I also have code that if the variable is expected to be a number, cast it to int.
    So I spent 1 day finding out that the user ID became 0, that's why all player data are overlapping
    Then I spent 2 days locating the place that it became 0
    Then I spent 1 day to find out that it has always been a string since fetched from MySQL.
    Then I spent 2 days to fix that in the whole LegionPE Eta plugin.
  7. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Actually.. Just a question, maybe related to this issue.
    I've got my chat to be able to save emojis into my db. I have UTF8_d4 or so as encoding.
    Also when i open the database in PMA (php my admin), i see the emojis.
    But i can't display them in my chat.. i tried to use komodo_emoji (a project on github), but anyways.. is there atleast a way so it shows the emojis in my chat?
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Does MCPE even support emoji?
    applqpak likes this.
  9. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Nope. xD :p

Share This Page

Advertisement