Hi I want to save RefreshMsg to file and later replay it, for chinese charactor, decode back with garbled charactor, can some one help figure out?
Here is the code:
cn_demo.txt
@jessie.deng
Thank you for reaching out to us.
The problem is the code directly encodes and decodes UTF8 as RMTES.
To encode UTF8 to RMTES, a UTF8 string must be prepended with the following three bytes escape sequence: 0x1B, 0x25, and 0x30, as mentioned in the Encoding and Decoding non-ASCII text using EMA and RFA C++/.NET article.
The sample code looks like this:
rsslFEntry.fieldId = 1352; rsslFEntry.dataType = RSSL_DT_RMTES_STRING; const char utf8_prefix[] = { 0x1B,0x25,0x30, 0 }; const char* value = "24附息國債07"; char* rmtes_value = (char*)malloc(strlen(utf8_prefix) + strlen(value)); strcpy(rmtes_value, utf8_prefix); strcat(rmtes_value, value); RsslBuffer vbuf = { 0 }; vbuf.data = rmtes_value; vbuf.length = strlen(rmtes_value);