Example - LayoutTransformText

This example creates a layout object then defines the values that need to be changed and uses the LayoutTransformText function to change them.

#include <layout.h>

LAYOUT_OBJECT plh;

UCHAR InpBuf[30];
UCHAR OutBuf[30];
UCHAR BidiLvl[30];
ULONG ToOutBuf[30];
ULONG ToInpBuf[30];
ULONG InpSize = 30  ;
ULONG OutSize = 30   ;
LAYOUT_VALUES layout[2];
LAYOUT_TEXT_DESCRIPTOR Descr;
ULONG index;
ULONG RC;

    RC= LayoutCreateObject (Locale_Arabic,&plh);  /* or: Locale_Hebrew */
    if (RC) { printf("Create Error! !!\n"); exit(0);}

   /* Define the LayoutValues that will need changing */
    layout[0].name= TypeOfText|Orientation|Numerals|TextShaping;
    layout[0].value = &Descr ;


   /* using the OR operator, we set the bits in the Layout Descriptor,
    * to describe the input string attributes, it is RTL, contains
    * Arabic numerals, and it is in Base shapes */

   Descr.in=TEXT_IMPLICIT|ORIENTATION_RTL|NUMERALS_NOMINAL|TEXT_NOMINAL;


   /* Now let's compose the Text Descriptor for the output string to be
    * LTR, Hindu numeral, and Shaped (Automatic Shape Determination) */

   Descr.out=TEXT_VISUAL|ORIENTATION_LTR| NUMERALS_CONTEXTUAL|TEXT_SHAPED;

    layout[1].name = 0 ;

    /* Set the LayoutValues   */
    RC=LayoutSetValues (plh,layout,&index);

  /* calling the function.. to convert the string */
    RC=LayoutTransformText (plh,
                      InpBuf,
                      &InpSize,
                      OutBuf,
                      &OutSize,
                      ToOutBuf,
                      ToInpBuf,
                      BidiLvl);

    if (RC) { printf("Transform Error %d!!!\n",RC); exit(0);}


  RC = LayoutDestroyObject(plh);
  if (RC) { printf(" DESTROY Error!!!\n"); exit(0);}
************************************************************


[Back: Notes - LayoutTransformText]
[Next: Related Functions - LayoutTransformText]