]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/ucnvdisp.c
2 ******************************************************************************
4 * Copyright (C) 1998-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
10 * Implements APIs for the ICU's codeset conversion library display names.
12 * Modification History:
14 * Date Name Description
15 * 04/04/99 helena Fixed internal header inclusion.
16 * 05/09/00 helena Added implementation to handle fallback mappings.
17 * 06/20/2000 helena OS/400 port changes; mostly typecast.
18 * 09/08/2004 grhoten split from ucnv.c
21 #include "unicode/utypes.h"
23 #if !UCONFIG_NO_CONVERSION
25 #include "unicode/ustring.h"
26 #include "unicode/ures.h"
27 #include "unicode/ucnv.h"
33 U_CAPI
int32_t U_EXPORT2
34 ucnv_getDisplayName(const UConverter
*cnv
,
35 const char *displayLocale
,
36 UChar
*displayName
, int32_t displayNameCapacity
,
37 UErrorCode
*pErrorCode
) {
41 UErrorCode localStatus
= U_ZERO_ERROR
;
44 if(pErrorCode
==NULL
|| U_FAILURE(*pErrorCode
)) {
48 if(cnv
==NULL
|| displayNameCapacity
<0 || (displayNameCapacity
>0 && displayName
==NULL
)) {
49 *pErrorCode
=U_ILLEGAL_ARGUMENT_ERROR
;
53 /* open the resource bundle and get the display name string */
54 rb
=ures_open(NULL
, displayLocale
, pErrorCode
);
55 if(U_FAILURE(*pErrorCode
)) {
59 /* use the internal name as the key */
60 name
=ures_getStringByKey(rb
, cnv
->sharedData
->staticData
->name
, &length
, &localStatus
);
63 if(U_SUCCESS(localStatus
)) {
65 if (*pErrorCode
== U_ZERO_ERROR
) {
66 *pErrorCode
= localStatus
;
68 u_memcpy(displayName
, name
, uprv_min(length
, displayNameCapacity
)*U_SIZEOF_UCHAR
);
70 /* convert the internal name into a Unicode string */
71 length
=(int32_t)uprv_strlen(cnv
->sharedData
->staticData
->name
);
72 u_charsToUChars(cnv
->sharedData
->staticData
->name
, displayName
, uprv_min(length
, displayNameCapacity
));
74 return u_terminateUChars(displayName
, displayNameCapacity
, length
, pErrorCode
);
80 * Hey, Emacs, please set the following:
83 * indent-tabs-mode: nil