The C++ API and the Java API both support Unicode for application data. This allows custom adapters to work with Unicode strings programmatically and to send and receive data between applications that use a variety of supported encodings. The data can be aggregated and serialized and then be sent over the network.
The C++ Adapter SDK includes the MChar and
MStringData classes to encapsulate Unicode data. Their constructors allow specifying the encoding for the source data. A complete list of supported encodings can be found in
MEncoding.h. You can also create an
MWString instance from either class, which allows you to call string manipulation methods against your data.
•
|
MString and MWString are used when you need string manipulation methods to operate on the data.
|
MString can encapsulate single-byte character data, while
MWString encapsulates Unicode (UTF-16) characters.
You must convert MString and
MWString to
MChar and
MStringData before sending them on the network.
•
|
MStringData and MChar are used to encapsulate Unicode data.
|
Custom adapters based on the TIBCO Adapter SDK automatically configure themselves to send or receive messages in ASCII/Latin-1 or in UTF-8 wire format, depending on how the associated server-based repository instance is configured.
Two adapters based on the SDK can communicate only if they use the same encoding on the wire. A problem arises if one adapter sends Latin-1 encoded messages to another adapter expecting UTF-8 encoded messages. Since the second adapter is expecting UTF-8 on the wire, Latin-1 characters are interpreted incorrectly.
SDK C++ API takes the encoding value from the repository and no other regional settings can affect the value of encoding. There can be only one encoding per process or application. If multiple
MApp application managers are running inside an SDK adapter, and each
MApp connects to a different repository, all the repositories must have the same encoding value.
Internally, the C++ SDK first decides to use one of two native implementations: Latin-1 for single-byte characters or UTF-16 for double-byte characters. Whether the SDK attempts conversion, and what conversion the SDK attempts depends on the encoding argument presented to the constructor for
MChar or
MStringData.
Set the environment variable TIB_ICU_DATA to point to the directory that contains the
tibicudata32.dat file. You need to set the variable manually. If SDK cannot find this file, it will throw an exception when you attempt to convert certain types of string encodings.
|
You can find the tibicudata32.dat file in the TIBCO Runtime Agent config/g11n directory. This directory also contains a tibicudata.dat file for backward compatibility with versions prior to SDK 5.3.
|
However, to maintain backward compatibility, only Adapter SDK encoding types listed in the
SDK_HOME\include\MEncoding.h should be used,
not common alias names listed on the site above.
The wire format encoding for messages affects all communications for adapter applications. Either Latin-1 or UTF-8 is supported as the wire format encoding when the adapter application is using a server-based project repositories.
All project repositories managed by a particular administration server use the same encoding. You can specify the wire format encoding as a server property (
repo.encoding) in the
tibcoadmin.tra file. To change the wire format encoding, shut down the server, edit the
tibcoadmin.tra file and then restart the server.
At some stages of a project, you may use a file-based repository. In that case, the encoding can be set in the project repository file itself. You can make the change using the Repository Finder in TIBCO Designer or editing the
.dat file directly.
<instanceInfoProperty name="encoding" value="desired_encoding"/>
The encoding only affects communication, it has no effect on the persistent storage of the data. TIBCO Administrator stores data in UTF-8 format regardless of the wire format encoding being used.
When an adapter application starts, the TIBCO Administrator client library forces both the instance name and discovery subject to conform to ASCII so that communication works with either encoding.
When the client is actually connecting to a server-based project repository for the first time, the encoding used by the server for that instance determines the encoding type for all TIBCO messages. The server encoding is determined by the
repo.encoding parameter in the
tibcoadmin.tra file.
All communicating applications must use the same wire format encoding. Therefore, all project repositories in use by applications that communicate with each other must use the same encoding. To understand the use of encoding formats, consider the following scenarios.
A client application with an embedded TIBCO Administrator client attempts to connect to two administration servers. In Scenario 1, the two servers use different encodings. In Scenario 2, the two servers use the same encodings.