Hello all, I'm trying to use tpl to serialize structs that contain wchar_t* strings.
The code I have looks like this, and it's not working:
#include <stdio.h>
#include <locale.h>
#include <string.h>
#include <wchar.h>
#include "tpl.h"
struct chinese_t {
wchar_t *chars;
};
int main() {
tpl_node *tn;
struct chinese_t cstr;
cstr.chars = L"字符串";
tn = tpl_map("S(s)", &cstr);
tpl_pack( tn, 0 );
tpl_dump(tn, TPL_FILE, "string.tpl");
tpl_free(tn);
struct chinese_t cstr2;
tn = tpl_map( "S(s)", &cstr2);
//tpl_load(tn, TPL_MEM, buffer, len);
tpl_load(tn, TPL_FILE, "string.tpl");
tpl_unpack(tn, 0);
tpl_free(tn);
printf("%ls\n", cstr2.chars);
return;
}
If I replace the Chinese "字符串" string with "1234" it just prints "1" -- if I change the definition so that the struct users a char* (and I only push ASCII characters into it) it works just fine. However I can't figure out how to get it to serialize and deserialize wchar_t* strings properly.