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?

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    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


Answers