2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2013-09-11 05:07:00 +00:00
|
|
|
/*
|
|
|
|
*****************************************************************************************
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (C) 2013, International Business Machines Corporation and others.
|
|
|
|
* All Rights Reserved.
|
2013-09-11 05:07:00 +00:00
|
|
|
*****************************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
|
|
|
#include "unicode/unumsys.h"
|
|
|
|
#include "unicode/numsys.h"
|
|
|
|
#include "unicode/uenum.h"
|
|
|
|
|
|
|
|
U_NAMESPACE_USE
|
|
|
|
|
|
|
|
|
|
|
|
U_CAPI UNumberingSystem* U_EXPORT2
|
|
|
|
unumsys_open(const char *locale, UErrorCode *status)
|
|
|
|
{
|
2013-09-12 04:33:03 +00:00
|
|
|
// createInstance returns immediately if status indicates error
|
2013-09-11 05:07:00 +00:00
|
|
|
return (UNumberingSystem*)NumberingSystem::createInstance(Locale(locale), *status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
U_CAPI UNumberingSystem* U_EXPORT2
|
|
|
|
unumsys_openByName(const char *name, UErrorCode *status)
|
|
|
|
{
|
2013-09-12 04:33:03 +00:00
|
|
|
// createInstanceByName does NOT return immediately if status indicates error
|
|
|
|
if (U_FAILURE(*status)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-09-11 05:07:00 +00:00
|
|
|
return (UNumberingSystem*)NumberingSystem::createInstanceByName(name, *status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
unumsys_close(UNumberingSystem *unumsys)
|
|
|
|
{
|
|
|
|
delete ((NumberingSystem*)unumsys);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
U_CAPI UEnumeration* U_EXPORT2
|
|
|
|
unumsys_openAvailableNames(UErrorCode *status)
|
|
|
|
{
|
2013-09-12 04:33:03 +00:00
|
|
|
// getAvailableNames returns immediately if status indicates error
|
2013-09-11 05:07:00 +00:00
|
|
|
return uenum_openFromStringEnumeration(NumberingSystem::getAvailableNames(*status), status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
U_CAPI const char * U_EXPORT2
|
2013-09-12 04:33:03 +00:00
|
|
|
unumsys_getName(const UNumberingSystem *unumsys)
|
2013-09-11 05:07:00 +00:00
|
|
|
{
|
|
|
|
return ((NumberingSystem*)unumsys)->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
2013-09-12 04:33:03 +00:00
|
|
|
unumsys_getRadix(const UNumberingSystem *unumsys)
|
2013-09-11 05:07:00 +00:00
|
|
|
{
|
|
|
|
return ((NumberingSystem*)unumsys)->getRadix();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
U_CAPI UBool U_EXPORT2
|
2013-09-12 04:33:03 +00:00
|
|
|
unumsys_isAlgorithmic(const UNumberingSystem *unumsys)
|
2013-09-11 05:07:00 +00:00
|
|
|
{
|
|
|
|
return ((NumberingSystem*)unumsys)->isAlgorithmic();
|
|
|
|
}
|
|
|
|
|
2013-09-12 04:33:03 +00:00
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
unumsys_getDescription(const UNumberingSystem *unumsys, UChar *result,
|
|
|
|
int32_t resultLength, UErrorCode *status)
|
|
|
|
{
|
|
|
|
if (U_FAILURE(*status)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
// implement
|
|
|
|
UnicodeString descrip = ((NumberingSystem*)unumsys)->getDescription();
|
|
|
|
return descrip.extract(result, resultLength, *status);
|
|
|
|
}
|
|
|
|
|
2013-09-11 05:07:00 +00:00
|
|
|
|
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|