]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/ulocdata.c
ICU-6.2.8.tar.gz
[apple/icu.git] / icuSources / i18n / ulocdata.c
1 /*
2 ******************************************************************************
3 * *
4 * Copyright (C) 2003-2004, International Business Machines *
5 * Corporation and others. All Rights Reserved. *
6 * *
7 ******************************************************************************
8 * file name: ulocdata.c
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2003Oct21
14 * created by: Ram Viswanadha
15 */
16
17 #include "unicode/ulocdata.h"
18
19 #define EXEMPLAR_CHARS "ExemplarCharacters"
20 #define MEASUREMENT_SYSTEM "MeasurementSystem"
21 #define PAPER_SIZE "PaperSize"
22
23 U_CAPI USet* U_EXPORT2
24 ulocdata_getExemplarSet(USet *fillIn, const char *localeID,
25 uint32_t options, UErrorCode *status){
26
27 UResourceBundle *bundle = NULL;
28 const UChar *exemplarChars = NULL;
29 int32_t len = 0;
30 UErrorCode localStatus = U_ZERO_ERROR;
31
32 if (U_FAILURE(*status)){
33 return NULL;
34 }
35
36 bundle = ures_open(NULL, localeID, status);
37 if (U_FAILURE(*status)) {
38 return NULL;
39 }
40
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;
44 }
45
46 if(fillIn != NULL){
47 uset_applyPattern(fillIn, exemplarChars, len,
48 USET_IGNORE_SPACE | options, status);
49 }else{
50 fillIn = uset_openPatternOptions(exemplarChars, len,
51 USET_IGNORE_SPACE | options, status);
52 }
53
54 ures_close(bundle);
55
56 return fillIn;
57
58 }
59
60 U_CAPI UMeasurementSystem U_EXPORT2
61 ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status){
62
63 UResourceBundle* bundle=NULL;
64 UResourceBundle* measurement=NULL;
65 UMeasurementSystem system = UMS_LIMIT;
66
67 if(status == NULL || U_FAILURE(*status)){
68 return system;
69 }
70
71 bundle = ures_open(NULL, localeID, status);
72
73 measurement = ures_getByKey(bundle, MEASUREMENT_SYSTEM, NULL, status);
74
75 system = (UMeasurementSystem) ures_getInt(measurement, status);
76
77 ures_close(bundle);
78 ures_close(measurement);
79
80 return system;
81
82 }
83
84 U_CAPI void U_EXPORT2
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;
89 int32_t len = 0;
90
91 if(status == NULL || U_FAILURE(*status)){
92 return;
93 }
94
95 bundle = ures_open(NULL, localeID, status);
96 paperSizeBundle = ures_getByKey(bundle, PAPER_SIZE, NULL, status);
97 paperSize = ures_getIntVector(paperSizeBundle, &len, status);
98
99 if(U_SUCCESS(*status)){
100 if(len < 2){
101 *status = U_INTERNAL_PROGRAM_ERROR;
102 }else{
103 *height = paperSize[0];
104 *width = paperSize[1];
105 }
106 }
107
108 ures_close(bundle);
109 ures_close(paperSizeBundle);
110
111 }