Accessibility

TechNote (Archived)

ColdFusion MX: Using double-byte data with C++ CFX tags

Issue


In order to use double-byte data in a C++ CFX with ColdFusion MX English, French, or German version, you must download and replace the CFXNeo.dll file. This .dll will force ColdFusion MX to convert data passed to and from the CFX as a multi-byte or unicode string.

ColdFusion MX is run in a J2EE environment so it fully supports all internationalization issues, however some changes were required to the C++ CFX subsystem since C++ is not based on unicode as Java is. Therefore, all double-byte characters will be corrupted if the C++ code sends a double-byte string to ColdFusion or if the C++ code manipulates the double-byte string. To solve this issue and support the previous C++ CFX tags as well, we provide two versions of the C++ CFX subsystem. One supports the single-byte C++ CFX tags and is fully compatible with all previous C++ tags which work with single-byte characters. ColdFusion MX English, French, and German are released with this single-byte version of the file. The second, which is available for download in the steps below, supports double-byte C++ CFX tags for those customers who use double-byte characters. ColdFusion MX Japanese and Korean are released with the double-byte version of the file.

Note: ColdFusion MX Japanese and Korean already have this double-byte CFXNeo.dll. If you are using one of those versions, you do not need to install this .dll.

ColdFusion 5 All strings are treated as a single byte.
ColdFusion MX (Single-byte CFXNeo.dll) Same as ColdFusion 5 (All strings will be treated as a single byte.)
ColdFusion MX (Double-byte CFXNeo.dll) Double-byte strings from ColdFusion MX will be converted to multi-byte strings before being sent to the C++ CFX and also when ColdFusion MX gets a string back from the C++ CFX, it will convert back the multi-byte string to a wide-char string. Therefore, users must convert all incoming data (multi-byte data) to wide characters before manipulating the data inside the C++ CFX code. Additionally, the data must be converted back to multi-byte data for output to ColdFusion MX since CFXNeo.dll will convert the multi-byte data back to unicode.

The following example will convert data from ColdFusion MX to wide character data and check the length of the data. Then it will convert back to multi-byte data and send it with the checked length.

 LPCSTR name = pRequest->GetAttribute("NAME") ;  // get a data from NAME parameter. int slen = strlen(name);  // get the size of received string /* ################################################     Convert Multi Byte data to Wide Character data    ################################################ */ // ALLOCATE MEMORY /////////////////////// int length = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)name, slen, NULL, 0 );  // get the length of wide-char wchar_t* wchar_name = (wchar_t*)malloc( length*2 + 1 );  // allocate a memory space for wide-char data // Convert from multi-byte data to wide-character data int len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)name, slen, (LPWSTR)wchar_name, length); char strLen[25]; sprintf(strLen, "%d", len);  // convert the length (int) to string to send  // back to ColdFusion /* ################################################     Convert back Wide Character data to Multi Byte data    ################################################ */ // ALLOCATE MEMORY /////////////////////// char* strSetting = (char*) malloc(len*2+1); // // convert to multi-byte data ///////////////////// int size = WideCharToMultiByte( CP_ACP, 0,  (LPWSTR)wchar_name, len, strSetting,  (len*2+1), NULL, NULL ); strSetting[size] = 0; pRequest->SetVariable("TMP_LEN", strLen);  // send back the length to TMP_LEN variable in  // ColdFusion template pRequest->SetVariable("TMP_STR", strSetting);  // send back the length to TMP_STR variable in  // ColdFusion template free(wchar_name);   // release the allocated memory free(strSetting);   // release the allocated memory 

Solution


  1. Download CFXNeo.dll (6K)
  2. Stop the ColdFusion MX Application Server Service
  3. Backup the existing CFXNeo.dll in cf_root\lib by renaming it.
  4. Copy the new CFXNeo.dll to cf_root\lib
  5. Start the ColdFusion MX Application Server Service


AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:tn_18270
Browser:Chrome
Internet Explorer
Netscape
Opera
Safari
Firefox
Database:DB2
Informix
MySQL
Oracle
SQL Server
Sybase
MS Access

Products Affected: