Jump to content

UniCreateTransformObject: Difference between revisions

From EDM2
Created page with "UniCreateTransformObject creates a string transform object. ==Syntax== int UniCreateTransformObject (const LocaleObject locale_object, const UniChar *xtype, XformObject *xfo..."
 
No edit summary
Line 6: Line 6:
==Parameters==
==Parameters==


locale_object  (const LocaleObject)
; locale_object  (const LocaleObject) : A locale object created by UniCreateLocaleObject or NULL.  
    A locale object created by UniCreateLocaleObject or NULL.  
; xtype  (const UniChar *) : A UniChar string identifying the transform type.  
xtype  (const UniChar *)
; xform_object  (XformObject *) : An address that will receive a pointer to an XformObject upon successful completion of UniCreateTransformObject.  
    A UniChar string identifying the transform type.  
xform_object  (XformObject *)
    An address that will receive a pointer to an XformObject upon successful completion of UniCreateTransformObject.  
 
Returns


==Returns==
Return value  (int)  -  returns
Return value  (int)  -  returns


ULS_SUCCESS
; ULS_SUCCESS : No errors; the xform_object argument points to a valid transformation object.  
    No errors; the xform_object argument points to a valid transformation object.  
; ULS_UNSUPPORTED : The transformation name type specified by the xtype argument is not supported for locale_object.  
ULS_UNSUPPORTED
    The transformation name type specified by the xtype argument is not supported for locale_object.  
 
Remarks


==Remarks==
UniCreateTransformObject obtains a transformation object for a transformation type as defined in the locale indicated by the locale_object argument. The function returns a transformation object that can be used as an argument in UniTransformStr.
UniCreateTransformObject obtains a transformation object for a transformation type as defined in the locale indicated by the locale_object argument. The function returns a transformation object that can be used as an argument in UniTransformStr.


The following transformation types are defined in all locales:
The following transformation types are defined in all locales:


lower
; lower : Transform to lowercase characters. A character that does not have a lowercase form is returned as itself.  
    Transform to lowercase characters. A character that does not have a lowercase form is returned as itself.  
; upper : Transform to uppercase characters. A character that does not have an uppercase form is returned as itself.  
upper
; compose : Transform to fully composed form for combined characters.  
    Transform to uppercase characters. A character that does not have an uppercase form is returned as itself.  
; decompose : Transform to a string of decomposed characters where multiple characters are used to represent base and diacritics.  
compose
; hiragana : Transform so that Japanese phonetic characters are in hiragana  
    Transform to fully composed form for combined characters.  
; katakana : Transform so that Japanese phonetic characters are in full size katakana  
decompose
; kana : Transform so that Japanese phonetic characters are in half size katakana  
    Transform to a string of decomposed characters where multiple characters are used to represent base and diacritics.  
hiragana
    Transform so that Japanese phonetic characters are in hiragana  
katakana
    Transform so that Japanese phonetic characters are in full size katakana  
kana
    Transform so that Japanese phonetic characters are in half size katakana  


In addition to the above transformation-type names, other transformation-type names in the locale (including user-defined transformation-type names) may be passed to UniCreateTransformObject through the xtype argument. To obtain a successful return, the transformation-type name must be defined in locale_object.
In addition to the above transformation-type names, other transformation-type names in the locale (including user-defined transformation-type names) may be passed to UniCreateTransformObject through the xtype argument. To obtain a successful return, the transformation-type name must be defined in locale_object.
Line 48: Line 34:




Example
==Example==


This example shows how to create and use a transform object.
This example shows how to create and use a transform object.
 
<PRE>
#include <stdio.h>
#include <stdio.h>
#include <unidef.h>
#include <unidef.h>
Line 98: Line 84:
     return ULS_SUCCESS;
     return ULS_SUCCESS;
}  
}  
 
<\PRE>
Format
===Format===
 
<PRE>
#include <unidef.h>
#include <unidef.h>


Line 109: Line 95:
)
)


 
<\PRE>
==Related Functions==
==Related Functions==
* [[UniFreeTransformObject]]


    UniFreeTransformObject
[[Category:Uni]]

Revision as of 01:44, 16 August 2017

UniCreateTransformObject creates a string transform object.

Syntax

int UniCreateTransformObject (const LocaleObject locale_object, const UniChar *xtype, XformObject *xform_object)

Parameters

locale_object (const LocaleObject)
A locale object created by UniCreateLocaleObject or NULL.
xtype (const UniChar *)
A UniChar string identifying the transform type.
xform_object (XformObject *)
An address that will receive a pointer to an XformObject upon successful completion of UniCreateTransformObject.

Returns

Return value (int) - returns

ULS_SUCCESS
No errors; the xform_object argument points to a valid transformation object.
ULS_UNSUPPORTED
The transformation name type specified by the xtype argument is not supported for locale_object.

Remarks

UniCreateTransformObject obtains a transformation object for a transformation type as defined in the locale indicated by the locale_object argument. The function returns a transformation object that can be used as an argument in UniTransformStr.

The following transformation types are defined in all locales:

lower
Transform to lowercase characters. A character that does not have a lowercase form is returned as itself.
upper
Transform to uppercase characters. A character that does not have an uppercase form is returned as itself.
compose
Transform to fully composed form for combined characters.
decompose
Transform to a string of decomposed characters where multiple characters are used to represent base and diacritics.
hiragana
Transform so that Japanese phonetic characters are in hiragana
katakana
Transform so that Japanese phonetic characters are in full size katakana
kana
Transform so that Japanese phonetic characters are in half size katakana

In addition to the above transformation-type names, other transformation-type names in the locale (including user-defined transformation-type names) may be passed to UniCreateTransformObject through the xtype argument. To obtain a successful return, the transformation-type name must be defined in locale_object.

When UniCreateTransformObject completes without errors, the xform_object argument value specifies a valid pointer to a transformation object. The transformation object should be used in all subsequent calls to UniTransformStr. If the function result is other than ULS_SUCCESS, the contents of the area pointed to by xform_object are undefined.


Example

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;
} 
<\PRE>

Format

#include <unidef.h>

int UniCreateTransformObject (
    const LocaleObject locale_object,    /* I  - Locale object    */
    const UniChar      *xtype,           /* I  - Transform type   */
    XformObject        *xform_object     /* O  - Transform object */
)

<\PRE>

Related Functions

* UniFreeTransformObject