question

Upvotes
Accepted
3 0 0 4

Encode RMTES_STRING vs ASCII_STRING in my IProvider

I am implementing my own IProvider following the sample [here](https://github.com/Refinitiv/Real-Time-SDK/blob/master/CSharp/Ema/Examples/Training/IProvider/100_Series/100_MP_Streaming/IProvider.cs)

In the RDMFieldDictionary file, I am aware that fields can at least be two types of strings, ASCII_STRING or RMTES_STRING.

Now I encode both of them with the same call:

FieldList fieldList = new FieldList();
// ...
fieldList.AddAscii(fid, "my string");

Is this practice correct?

#productrefinitiv-realtime-sdk
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.

Upvotes
Accepted
27.2k 65 17 14

Hello @vnaik01

The code that you encode the ASCII string is valid.

  • The ASCII is for the ASCII field data.
  • The RMTES is for the RMTES_STRING (non-ASCII) character field data

You can see the field type information and definition on the RDMFieldDictionary file in the etc folder of the RTSDK package.

Example:
!ACRONYM    DDE ACRONYM          FID  RIPPLES TO  FIELD TYPE     LENGTH  RWF TYPE   RWF LEN
!-------    -----------          ---  ----------  ----------     ------  --------   -------
DSPLY_NAME "DISPLAY NAME"           3  NULL        ALPHANUMERIC       16  RMTES_STRING    16
!
! Full or abbreviated text instrument name.
!
SEG_FORW   "FORWARD TAKE"         260  NULL        ALPHANUMERIC       14  ASCII_STRING    14
!
! Forward pointer initially used by PPD to point to the next take of a story.
!

About how to encode the RMTES string, you can use the same logic from this Encoding and Decoding non-ASCII text using EMA and RFA C++/.NET article.

1724839289361.png

Example Code:

string utf8String = "匯豐控股";
var bytesOne = new byte[] { 0x1B, 0x25, 0x30 };
var bytesTwo = Encoding.UTF8.GetBytes(utf8String);
byte[] byteRMTES = new byte[bytesOne.Length + bytesTwo.Length];


for (int i = 0; i < byteRMTES.Length; ++i)
{
    byteRMTES[i] = i < bytesOne.Length ? bytesOne[i] : bytesTwo[i - bytesOne.Length];
}


EmaBuffer emaBuffer = new();
emaBuffer.CopyFrom(byteRMTES);


FieldList fieldList = new FieldList();
fieldList.AddReal(22, 3990, OmmReal.MagnitudeTypes.EXPONENT_NEG_2);
fieldList.AddReal(25, 3994, OmmReal.MagnitudeTypes.EXPONENT_NEG_2);
fieldList.AddReal(30, 9, OmmReal.MagnitudeTypes.EXPONENT_0);
fieldList.AddReal(31, 19, OmmReal.MagnitudeTypes.EXPONENT_0);
fieldList.AddAscii(260, "Test Message"); //SEG_FORW 
fieldList.AddRmtes(1352, emaBuffer); //DSPLY_NMLL


providerEvent.Provider.Submit(new RefreshMsg()
    .Name(reqMsg.Name()).ServiceName(reqMsg.ServiceName())
    .Solicited(true)
    .State(OmmState.StreamStates.OPEN, OmmState.DataStates.OK, OmmState.StatusCodes.NONE, "Refresh Completed")
    .Payload(fieldList.Complete()).Complete(true),
    providerEvent.Handle);


ItemHandle = providerEvent.Handle;

Please be notice that:

  • The first 3 bytes characters are 0x1B, 0x25 and 0x30. They are mandatory escape sequence characters used by data feed component for the text encoded with UTF-8

Result: (from the EMA Java: ex360_MP_View which is equivalent to the EMA C# Con360_MP_View example)

result-java.png



1724839289361.png (33.2 KiB)
result-java.png (79.6 KiB)
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.

Upvotes
27.2k 65 17 14

Hello @vnaik01

Please be informed that the LSEG Real-Time Platform use the RMTES for non-ASCII characters.

You can find more information from my colleague answered on this old post.

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.

Upvotes
3 0 0 4

Hi @wasin.w ,


According to the samples in [Real-Time SDK](https://github.com/Refinitiv/Real-Time-SDK), I am doing these calls to add values to a message:

var fieldList = new FieldList();


fieldList.AddReal(31, 19, OmmReal.MagnitudeTypes.EXPONENT_0);
fieldList.AddAscii(33, "asd");
fieldList.AddEnumValue(14, 1);


var updMsg = new UpdateMsg().DomainType(EmaRdm.MMT_MARKET_PRICE).Name(ric).Payload(fieldList.Complete());

I checked the post you referred to as well as this [blog post](https://developers.lseg.com/en/article-catalog/article/encoding-and-decoding-non-ascii-text-using-ema-and-rfa-cnet) mentioned in the post you quoted, it does not seem to have a C# version of the encoding part.

Can you let me have a C# example demonstrating how exactly I should use the C# SDK like [this one](https://github.com/Refinitiv/Real-Time-SDK/blob/205a7827ef762d3d672a9cec6df12f0656e7a6b0/CSharp/Ema/Examples/Training/IProvider/100_Series/100_MP_Streaming/IProvider.cs#L53-L57)?

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.

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.