ErikMinekus / sm-ripext

SourceMod REST in Pawn Extension
https://forums.alliedmods.net/showthread.php?t=298024
GNU General Public License v3.0
133 stars 38 forks source link

JSONObject.SetString and special characters not working? #13

Closed muukis closed 4 years ago

muukis commented 6 years ago

Using special characters on SetString fails, or at least GetString cannot find the set key. I posted the issue also to AlliedModders thread.

Here's an example: `JSONObject obj = new JSONObject(); obj.SetString("test", "ð");

decl String:test[10]; obj.GetString("test", test, sizeof(test));

[SM] Native "JSONObject.GetString" reported: Could not retrieve value for key 'test'`

ErikMinekus commented 6 years ago

@muukis Sorry for the late response. I just tested that code, but I wasn't able to reproduce the issue:

#include <sourcemod>
#include <ripext>

public void OnPluginStart()
{
    JSONObject obj = new JSONObject();
    obj.SetString("test", "ð");

    char test[10];
    obj.GetString("test", test, sizeof(test));

    delete obj;
    PrintToServer("Test %s", test); // Output: Test ð
}

Both of your examples from the AlliedModders thread worked for me as well.

If you're still having this issue, could you provide the extension version, SourceMod version, and which game you're running it on?