scuffed-code/tools/colprobe/longname.cpp
George Rhoten 5bd3f677d5 ICU-4301 Remove executable svn property
X-SVN-Rev: 21927
2007-07-09 07:19:39 +00:00

49 lines
1.3 KiB
C++

#include "unicode/unistr.h"
#include "unicode/locid.h"
#include "unicode/ucnv.h"
#include <stdio.h>
int main(int argc,
char* argv[])
{
UErrorCode status = U_ZERO_ERROR;
const char *loc = argv[1];
int32_t hasCountry;
UConverter *conv = ucnv_open("utf8", &status);
UChar UBuffer[256];
int32_t uBufLen = 0;
char buffer[256];
int32_t bufLen = 0;
uBufLen = uloc_getDisplayLanguage(loc, "en", UBuffer, 256, &status);
bufLen = ucnv_fromUChars(conv, buffer, 256, UBuffer, uBufLen, &status);
//u_UCharsToChars(UBuffer, buffer, uBufLen);
buffer[bufLen] = 0;
printf("%s", buffer);
if(hasCountry = uloc_getCountry(loc, buffer, 256, &status)) {
uBufLen = uloc_getDisplayCountry(loc, "en", UBuffer, 256, &status);
bufLen = ucnv_fromUChars(conv, buffer, 256, UBuffer, uBufLen, &status);
//u_UCharsToChars(UBuffer, buffer, uBufLen);
buffer[bufLen] = 0;
printf("_%s", buffer);
}
if(uloc_getVariant(loc, buffer, 256, &status)) {
uBufLen = uloc_getDisplayVariant(loc, "en", UBuffer, 256, &status);
bufLen = ucnv_fromUChars(conv, buffer, 256, UBuffer, uBufLen, &status);
//u_UCharsToChars(UBuffer, buffer, uBufLen);
buffer[bufLen] = 0;
if(!hasCountry) {
printf("_");
}
printf("_%s", buffer);
}
printf("\n");
return 0;
}