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
-
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.
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)
0
Answers
-
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)?
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛