Thursday, February 12, 2009

Essbase API for Unicode Applications

Recently we had a user report that the OlapUnderground Essbase Outline Extractor, which we now maintain and distribute, does not work with Unicode outlines. I had never tried working with a Unicode outline but I had my assistant take a look at it and sure enough, it didn't work. Upon further investigation, I found the ESB_INIT_T structure has a new parameter to handle Unicode (UTF-8) encoding:

' Essbase ESB Initialization Structure
Version As Long
MaxHandles As Integer
LocalPath As String * ESB_PATHLEN
MessageFile As String * ESB_PATHLEN
HelpFile As String * ESB_PATHLEN
ClientError As Integer
ErrorStack As Integer
usApiType As Integer
vbCallbackFuncAddress As Long
End Type

The usApiType parameter takes one of two constants as a parameter:

Global Const ESB_API_UTF8 = &H3

If you don't pass a value, the default value internally must be non-unicode as the ESB_API_NONUNICODE value is non-zero value but non-unicode applications work.

In the Outline Extractor, there is a catch-22 in the code. The EsbInit function gets called before the application can know whether the outline being targeted is from a Unicode application. We have added a checkbox to the user interface so a user can indicate if the outline being targeted from a Unicode application.

We still have one issue to work through before the Outline Extractor functions with Unicode. Visual Basic 6 does not write strings in UTF-8 encoding but rather uses ASCII encoding. Writing the strings produced by native VB6 to a file writes the wrong encoding and thus certain characters change. We still need to update the file writing algorithm to properly write the strings before we release it.

Most of my programming these days is in Java; encoding seems to be much easier in Java. Further, I do not believe a parameter like usApiType is necessary in the Essbase Java API.

No comments: