mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-165 return converters from api, not aliases
X-SVN-Rev: 395
This commit is contained in:
parent
70b4238f27
commit
043cf32ee0
4 changed files with 60 additions and 7 deletions
|
@ -399,11 +399,11 @@ UnicodeConverterCPP::getAvailableNames(int32_t& num, UErrorCode& err)
|
|||
return NULL;
|
||||
}
|
||||
if (availableConverterNames==NULL) {
|
||||
int32_t count = ucnv_io_countAvailableAliases(&err);
|
||||
int32_t count = ucnv_io_countAvailableConverters(&err);
|
||||
if (count > 0) {
|
||||
const char **names = new const char *[count];
|
||||
if (names != NULL) {
|
||||
ucnv_io_fillAvailableAliases(names, &err);
|
||||
ucnv_io_fillAvailableConverters(names, &err);
|
||||
|
||||
/* in the mutex block, set the data for this process */
|
||||
umtx_lock(0);
|
||||
|
|
|
@ -278,7 +278,7 @@ const char* ucnv_getAvailableName (int32_t index)
|
|||
{
|
||||
if (0 <= index && index <= 0xffff) {
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
const char *name = ucnv_io_getAvailableAlias((uint16_t)index, &err);
|
||||
const char *name = ucnv_io_getAvailableConverter((uint16_t)index, &err);
|
||||
if (U_SUCCESS(err)) {
|
||||
return name;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ const char* ucnv_getAvailableName (int32_t index)
|
|||
int32_t ucnv_countAvailable ()
|
||||
{
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
return ucnv_io_countAvailableAliases(&err);
|
||||
return ucnv_io_countAvailableConverters(&err);
|
||||
}
|
||||
|
||||
void ucnv_getSubstChars (const UConverter * converter,
|
||||
|
|
|
@ -259,6 +259,38 @@ ucnv_io_getAlias(const char *alias, uint16_t index, UErrorCode *pErrorCode) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
U_CFUNC uint16_t
|
||||
ucnv_io_countAvailableConverters(UErrorCode *pErrorCode) {
|
||||
if(haveAliasData(pErrorCode)) {
|
||||
return aliasTable[1+2*(*aliasTable)];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_CFUNC const char *
|
||||
ucnv_io_getAvailableConverter(uint16_t index, UErrorCode *pErrorCode) {
|
||||
if(haveAliasData(pErrorCode)) {
|
||||
const uint16_t *p=aliasTable+1+2*(*aliasTable);
|
||||
if(index<*p) {
|
||||
return (const char *)aliasTable+p[1+2*index];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U_CFUNC void
|
||||
ucnv_io_fillAvailableConverters(const char **aliases, UErrorCode *pErrorCode) {
|
||||
if(haveAliasData(pErrorCode)) {
|
||||
const uint16_t *p=aliasTable+1+2*(*aliasTable);
|
||||
uint16_t count=*p++;
|
||||
while(count>0) {
|
||||
*aliases++=(const char *)aliasTable+*p;
|
||||
p+=2;
|
||||
--count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U_CFUNC uint16_t
|
||||
ucnv_io_countAvailableAliases(UErrorCode *pErrorCode) {
|
||||
if(haveAliasData(pErrorCode)) {
|
||||
|
@ -270,7 +302,7 @@ ucnv_io_countAvailableAliases(UErrorCode *pErrorCode) {
|
|||
U_CFUNC const char *
|
||||
ucnv_io_getAvailableAlias(uint16_t index, UErrorCode *pErrorCode) {
|
||||
if(haveAliasData(pErrorCode) && index<*aliasTable) {
|
||||
return (const char *)aliasTable+*(aliasTable+1+2*index);
|
||||
return (const char *)aliasTable+*(aliasTable+1+index);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -282,7 +314,7 @@ ucnv_io_fillAvailableAliases(const char **aliases, UErrorCode *pErrorCode) {
|
|||
uint16_t count=*p++;
|
||||
while(count>0) {
|
||||
*aliases++=(const char *)aliasTable+*p;
|
||||
p+=2;
|
||||
++p;
|
||||
--count;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,27 @@ ucnv_io_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCo
|
|||
U_CFUNC const char *
|
||||
ucnv_io_getAlias(const char *alias, uint16_t index, UErrorCode *pErrorCode);
|
||||
|
||||
/**
|
||||
* Return the number of all converter names.
|
||||
*/
|
||||
U_CFUNC uint16_t
|
||||
ucnv_io_countAvailableConverters(UErrorCode *pErrorCode);
|
||||
|
||||
/**
|
||||
* Return the (index)th converter name in mixed case, or NULL
|
||||
* if there is none (typically, if the data cannot be loaded).
|
||||
* 0<=index<ucnv_io_countAvailableConverters().
|
||||
*/
|
||||
U_CFUNC const char *
|
||||
ucnv_io_getAvailableConverter(uint16_t index, UErrorCode *pErrorCode);
|
||||
|
||||
/**
|
||||
* Fill an array const char *aliases[ucnv_io_countAvailableConverters()]
|
||||
* with pointers to all converter names in mixed-case.
|
||||
*/
|
||||
U_CFUNC void
|
||||
ucnv_io_fillAvailableConverters(const char **aliases, UErrorCode *pErrorCode);
|
||||
|
||||
/**
|
||||
* Return the number of all aliases (and converter names).
|
||||
*/
|
||||
|
@ -53,7 +74,7 @@ ucnv_io_countAvailableAliases(UErrorCode *pErrorCode);
|
|||
/**
|
||||
* Return the (index)th alias or converter name in mixed case, or NULL
|
||||
* if there is none (typically, if the data cannot be loaded).
|
||||
* 0<=index<=ucnv_io_countAvailableAliases().
|
||||
* 0<=index<ucnv_io_countAvailableAliases().
|
||||
*/
|
||||
U_CFUNC const char *
|
||||
ucnv_io_getAvailableAlias(uint16_t index, UErrorCode *pErrorCode);
|
||||
|
|
Loading…
Add table
Reference in a new issue