ESL Double Byte Character Support library has not been extensively tested and is not certified for production use, but we will provide support for it should you use it and experience any problems.
Please do let us have any feed-back regarding the functionality.
Whilst the library is called ESLDBCS as a reference to the support for Double Byte Character Sets (such as Japanese), which require two bytes per character. The actual functions work with Multi Byte Character Sets (MBCS), allowing for both the Western Single Byte Character Sets (SBCS) and Eastern Double Byte Character Sets (DBCS).
If your ESL application uses purely DBCS, then the existing functions and routines will work provided you account for the fact that lengths and positions are always supplied or returned in number of bytes, which therefore will need to be divided or multiplied by two.
The demonstration consists of 1 ESL application, an include file to declare the MBCS functions, the ESLDBCS DLL (library) and an image in Jpeg format showing the expected results from the demonstration program. In order to run the ESL Application the computer must have the Japanese code page conversion table loaded and be configured to use Japanese as the language version of the non-Unicode programs. As none of the ESL Syndetic staff can read or write Japanese the characters used are purely randomly selected and we trust they do not offend any Japanese readers.
A common approach to simplify support for MBCS is to use Unicode. In a Unicode string, all characters appear as 2 bytes. Unfortunately, any single byte character is padded using a NULL, which is interrupted by the string handling functions (such as "extract") as an end of string. However, as ESL string variables are able to store NULLS the following 2 functions allow conversion:
function EslMBCS2Unicode (string: MBCSString)
returns string
library "esldbcs"
function EslUnicode2MBCS (string: UniString)
returns string
library "esldbcs"
Note. The fileIO routine, "WriteString" has been updated to enable string with embedded NULLS to be written to file, therefore ESL can now create a file for input into a UniCode application.
To determine the number of Characters in a MBCS use the function:
function EslMBCSLength (string: MBCSString)
returns integer
library "esldbcs"
To search a MBCS string for a sequence of characters, use:
function EslMBCSSearchString (string: MBCSString,
string: SearchString)
returns integer
library "esldbcs"
This function returns an index for the first character position that the sequence of characters was found, starting at the left character (position 1) and scanning to the right of the MBCS string. If the sequence of characters is not found, zero is returned. If the sequence of characters is longer than the MBCS String, then -1 is returned. The value -2 is returned if there are any internal processing errors.
To enable the extraction of part of a MBCS String, the following routines are available:
function EslMBCSRightString (string: MBCSString,
integer: Index)
returns string
library "esldbcs"
Returns a string of the characters to the right of the indexed character.
function EslMBCSLeftString (string: MBCSString,
integer: Index)
returns string
library "esldbcs"
Returns a string of the characters to the left of the indexed character.
function EslMBCSSubString (string: MBCSString,
integer: Index,
integer: Length)
returns string
library "esldbcs"
Returns a string of the characters starting at the indexed character, for the specified length of characters.
If there is any error with the parameters specified for these "extraction" functions, then a zero length string is returned.