2 ******************************************************************************
4 * Copyright (C) 2003-2004, International Business Machines *
5 * Corporation and others. All Rights Reserved. *
7 ******************************************************************************
8 * file name: ulocdata.c
10 * tab size: 8 (not used)
13 * created on: 2003Oct21
14 * created by: Ram Viswanadha
17 #include "unicode/ulocdata.h"
19 #define EXEMPLAR_CHARS "ExemplarCharacters"
20 #define MEASUREMENT_SYSTEM "MeasurementSystem"
21 #define PAPER_SIZE "PaperSize"
23 U_CAPI USet
* U_EXPORT2
24 ulocdata_getExemplarSet(USet
*fillIn
, const char *localeID
,
25 uint32_t options
, UErrorCode
*status
){
27 UResourceBundle
*bundle
= NULL
;
28 const UChar
*exemplarChars
= NULL
;
30 UErrorCode localStatus
= U_ZERO_ERROR
;
32 if (U_FAILURE(*status
)){
36 bundle
= ures_open(NULL
, localeID
, status
);
37 if (U_FAILURE(*status
)) {
41 exemplarChars
= ures_getStringByKey(bundle
, EXEMPLAR_CHARS
, &len
, &localStatus
);
42 if (U_FAILURE(localStatus
) || (*status
!= U_USING_DEFAULT_WARNING
&& localStatus
!= U_ZERO_ERROR
)) {
43 *status
= localStatus
;
47 uset_applyPattern(fillIn
, exemplarChars
, len
,
48 USET_IGNORE_SPACE
| options
, status
);
50 fillIn
= uset_openPatternOptions(exemplarChars
, len
,
51 USET_IGNORE_SPACE
| options
, status
);
60 U_CAPI UMeasurementSystem U_EXPORT2
61 ulocdata_getMeasurementSystem(const char *localeID
, UErrorCode
*status
){
63 UResourceBundle
* bundle
=NULL
;
64 UResourceBundle
* measurement
=NULL
;
65 UMeasurementSystem system
= UMS_LIMIT
;
67 if(status
== NULL
|| U_FAILURE(*status
)){
71 bundle
= ures_open(NULL
, localeID
, status
);
73 measurement
= ures_getByKey(bundle
, MEASUREMENT_SYSTEM
, NULL
, status
);
75 system
= (UMeasurementSystem
) ures_getInt(measurement
, status
);
78 ures_close(measurement
);
85 ulocdata_getPaperSize(const char* localeID
, int32_t *height
, int32_t *width
, UErrorCode
*status
){
86 UResourceBundle
* bundle
=NULL
;
87 UResourceBundle
* paperSizeBundle
= NULL
;
88 const int32_t* paperSize
=NULL
;
91 if(status
== NULL
|| U_FAILURE(*status
)){
95 bundle
= ures_open(NULL
, localeID
, status
);
96 paperSizeBundle
= ures_getByKey(bundle
, PAPER_SIZE
, NULL
, status
);
97 paperSize
= ures_getIntVector(paperSizeBundle
, &len
, status
);
99 if(U_SUCCESS(*status
)){
101 *status
= U_INTERNAL_PROGRAM_ERROR
;
103 *height
= paperSize
[0];
104 *width
= paperSize
[1];
109 ures_close(paperSizeBundle
);