This example shows how to create and use a transform object.

#include <stdio.h>
#include <unidef.h>

int main(void) {

LocaleObject locale_object = NULL;
XformObject  xform_object = NULL;

int          rc = ULS_SUCCESS;
int          in_unistr_elem = 0;
int          out_unistr_elem = 10;
UniChar      *pin_unistr = (UniChar *)L"os2";
UniChar      out_unistr[10];


         /*****************************************************************/
         /* Assumes LANG environment variable set to a valid locale name, */
         /* such as fr_FR                                              */
         /*****************************************************************/

         rc = UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
                                   (UniChar *)L"",
                                   &locale_object);

         if (rc != ULS_SUCCESS) {
           printf("UniCreateLocaleObject error: return code = %u\n",
                  rc);
           return 1;
         }

         /* Create an upper case transform object */

         rc = UniCreateTransformObject(locale_object,
                                      (UniChar *)L"upper",
                                      &xform_object);

         if (rc != ULS_SUCCESS) {
           printf("UniCreateTransformObject error: return code = %u\n",
                  rc);
           return 1;
         }

         /* Calculate the number of elements to transform */

         in_unistr_elem = UniStrlen (pin_unistr) + 1;

         /* Make call to transform input string to uppercase */

         rc = UniTransformStr(xform_object,
                             pin_unistr,
                             &in_unistr_elem,
                             out_unistr,
                             &out_unistr_elem);

         if (rc != ULS_SUCCESS) {
           printf("UniTransformStr error: return code = %u\n",
                  rc);
           return 1;
         }

         return ULS_SUCCESS;


}


[Back: UniCreateTransformObject - Related Functions]
[Next: UniCreateTransformObject - Topics]