UniQueryCountryName

From EDM2
Jump to: navigation, search

UniQueryCountryName returns the name of the country in the language specified.

Syntax

int UniQueryCountryName (UniChar * country, UniChar * isolang, UniChar * * infoitem) 

Parameters

country (UniChar *) 
The two character ID of the country to query.
isolang (UniChar *) 
The two character ID of the language used to return the country name.
infoitem (UniChar * *) 
A pointer to the country name.

Returns

Return Value (int) - returns

UniQueryCountryName returns one of the following values:

ULS_INVALID 
The country ID supplied is not known.
is returned upon success and the country name has been returned to the caller.

Remarks

This function only queries system provided locales to determine valid country names.

Example

This example shows how to query a country name.

#include <stdio.h>

#include <unidef.h>
#include <ulsitem.h>
 
int main(void) {
LocaleObject locale_object = NULL;
int          result = 0;
int          rc = ULS_SUCCESS;
UniChar      *pinfo;
UniChar      *langName;
UniChar      *countryName;
UniChar      *mriLanguage;
UniChar      uni_char = L'5';    /* Unicode number 5 character */
 
    /*****************************************************************/
    /* 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;
    }
 
    /* Determine the language to get the country name in */
    rc = UniQueryLocaleItem(locale_object, LOCI_sLanguageID,
            &mriLanguage);

    if (rc != ULS_SUCCESS) {
        printf("UniQueryLocaleItem error: return code = %u\n", rc);
        return 1;
    }
 
    /* Get the ISO country ID    
    rc = UniQueryLocaleItem(locale_object, LOCI_sCountryID, &pinfo);

    if (rc != ULS_SUCCESS) {
       printf("UniQueryLocaleItem error: return code = %u\n", rc);
       return 1;
    }
 
    /* Now we can determine the country name in the proper language */
    rc = UniQueryCountryName(pinfo, mriLanguage, &countryName);

    if (rc != ULS_SUCCESS) {
       printf("UniQueryCountryName error: return code = %u\n", rc);
       return 1;
    }
 
   printf("Country name is = %ls\n", countryName);

return ULS_SUCCESS;
}

Format

#include <unidef.h>

int UniQueryCountryName
    (UniChar * country, UniChar * isolang, UniChar * * infoitem) 

Related Functions