Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Web Service Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

20.4 Creating a Custom Character Converter

This discussion is based on the existing DayOfWeek example. DayOfWeek is a service that creates a simple server to return the day of the week for any date entered. It is located in your <installdir>\tutorials\webservices\DayOfWeek directory.

While the regular example returns the day in English, perhaps you wish to modify the server to return the day in Japanese. You could modify the server method to output the string in Shift-JIS, convert it to UTF-8, and send it as a SOAP response over the wire. The client could then convert it back to Shift-JIS. The resulting output would then be the Shift-JIS representation of the day of the week.

Creating a custom converter requires the following steps:

The following sections discuss these steps. In addition, note that the discussion is Windows-based.

20.4.1 Generate Code

Generate code, as always. For example,

You do not need to explicitly link in the ICU libraries, as that is performed automatically at runtime.

20.4.2 Create the Converter

HydraExpress offers several options for creating custom converters. The option discussed in this section creates a converter that uses the class RWUFromUnicodeConverter from the Internationalization Module of SourcePro Core.

Assuming you are building a DayOfWeek service that returns the day in Japanese, you would need a converter to and from UTF-8 and Shift-JIS.

For example, the following code

creates a server-side converter from that will convert from Unicode (UTF-8) to Shift-JIS.

The application could then define a set of arrays to hold each weekday in Japanese.

//1Uses a set of hexadecimal values for each UTF-16 code point. For more information on Unicode, see the Internationalization Module's User's Guide at the location noted below.

The client can now convert the strings to Shift-JIS. Here's an example of how that could be done:

For each day that matches the day string, this code generates an RWUString from the UTF-16 character string and then uses RWUString.toBytes to return an RWCString containing Shift_JIS using the converter from.

For more information on performing conversions and manipulating string data in various character encodings, see the Internationalization Module User's Guide on the Rogue Wave website (From http://www.roguewave.com, select Support | Product Documentation | SourcePro® C ++ Edition 9 | Internationalization Module User's Guide.)


When you create custom code for inclusion in a HydraExpress project, you must copy the header file to your code generation directory at \include\project name.


Previous fileTop of DocumentContentsIndex pageNext file

©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.