Question Problem retrieving data (wchar_t)

LoneWolf78

New member
Joined
Aug 4, 2017
Messages
4
Programming Experience
Beginner
Hi, i'm getting started with C# and have followed some tutorials and stuff and everything is going ok.

That is until the following problem occurd.

i have a char array like

C#:
wchar_t    identity[256];

and this is holding information (json) like this character by character. but each time i reach the double quotes my loop stops (breaks, or how you want to call it) so the output would be only the first "{"

C#:
{
  "name":"Irwene",
  "profession": 4,
  "race": 4,
  "map_id": 50,
  "world_id": 268435505,
  "team_color_id": 0,
  "commander": false,
  "fov": 0.873
}

how can i convert this to json using 'newtonsoft json'

this might be like a easy question, but i'm still learning. so any exmaple or push in the right direction is appriciated.
In the mean time i'll keep searching.

Thank you in advance.
 
Last edited:
'wchar_t' is a C/C++ data type. Why do you have an array of that type in C#?

Well because of this I guess.

MumbleLink structure

The MumbleLink specification is a Memory Shared File named "MumbleLink" using the following structure:

struct LinkedMem {
#ifdef WIN32
UINT32 uiVersion;
DWORD uiTick;
#else
uint32_t uiVersion;
uint32_t uiTick;
#endif
float fAvatarPosition[3];
float fAvatarFront[3];
float fAvatarTop[3];
wchar_t name[256];
float fCameraPosition[3];
float fCameraFront[3];
float fCameraTop[3];
wchar_t identity[256];
#ifdef WIN32
UINT32 context_len;
#else
uint32_t context_len;
#endif
unsigned char context[256];
wchar_t description[2048];
};

but I already slolved this problem this way after alot of trial and error.

C#:
var link = new MumbleLink();
MumbleLinkedMemory MumbleData = link.Read();
var identity = MumbleData.Identity;
var stop = Array.IndexOf(MumbleData.Identity, '\0');
unsafe
    {
        fixed (char* addr = identity)
    {
         return JsonConvert.DeserializeObject<GW2Identity>(new String(addr));
 
Back
Top Bottom