question

Upvotes
Accepted
154 18 24 35

How to use RFA C++ to handle Chinese characters in the DSPLY_NMLL field of 0981.HK

I have implemented RFA MarketDataSubscriber interface to subscribe data from 0981.HK RIC. I expect to receive Chinese character in the DSPLY_NMLL field, but the TibMsg::PrintTib() method prints the following output.

DSPLY_NMLL : STRING 20 : [^[$*5^[}à ãÃÃÃÃë㡾仡¿]

treprfarfa-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

This is a seed question.

1 Answer

· Write an Answer
Upvotes
Accepted
11.3k 25 9 14

The data type of the DSPLY_NMLL field is RMTES_STRING whose data is encoded with the Reuters Multilingual Text Encoding Standard (RMTES). RMTES uses ISO 2022 escape sequences to select the character sets used.

The TibMsg API provided in the RFA package provides conversion functionality to convert RMTES encoded strings received through Market Feed connections to Unicode string. The functions are TibMsg::ConvertToUTF8() which converts MarketFeed string data to UTF8 string data and TibMsg::ConvertToUCS2() which converts MarketFeed string data to UCS2 string data. For more information, please see the “12.3.13. TibMsg::ConvertToUCS2, TibMsg::ConvertToUTF8” section in the TibMsg API programming guide document (tmsgapi.pdf) provided in the RFA C++ package.

For other APIs, please see the information in this question.

Please see the following codes for the example code.

  err = tMsg.Get("DSPLY_NMLL",  fldTmp);

  if (!err.code)
  {
      char str_data[512];
      if (fldTmp.Type() == TIBMSG_STRING && fldTmp.HintType() ==
  TIBMSG_NODATA) 
      {
           printf("%s:  \n", fldTmp.Name());
           strncpy(str_data, (char*)fldTmp.Data(), fldTmp.Size());
           str_data[fldTmp.Size()]  = '\0';

           printf("String data : %s\n", str_data);
           Tib_i32  conv_len = 0;
           
           // UTF8 - 1 char can be 3 chars
           char *UTF8_data = new char[(fldTmp.Size()  * 3) + 1];
           TibErr err = TibMsg::ConvertToUTF8((char*)fldTmp.Data(), fldTmp.Size(), UTF8_data,(fldTmp.Size() * 3) + 1, conv_len);
  
           // UCS2 - 1 char can be 2 chars
           unsigned short*  ucs2_data = new unsigned short[(fldTmp.Size() * 2) + 1];
           err = TibMsg::ConvertToUCS2((char*)fldTmp.Data(), fldTmp.Size(), ucs2_data,(fldTmp.Size() * 2) + 1, conv_len);

           delete[] UTF8_data;
           delete[] ucs2_data;
           printf("\n"); }
       }
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Would it be possible to share again the TibMsg API programming guide document (tmsgapi.pdf)? Due to we could not open the link.

Thank you.

Hi,

The document is only available in RFA C++ 7.6.x package (except 7.6.2.E3 which doesn't contain the document). You can download RFA C++ package in this page.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.