ICU4C austrdup函数

问题描述 投票:0回答:1

我正在尝试在ICU4C下运行代码演示,并获得

警告:函数'austrdup'的隐式声明

随后会产生错误。我知道这是由于缺少包含“ austrdup”功能的导入库而引起的,并且一直在查看源代码以猜测它是哪一个,但是没有运气。有谁知道应该导入哪个?

#include <unicode/umsg.h>
#include <unicode/ustring.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(int argc, char const *argv[])
{
    UChar* str;
    UErrorCode status = U_ZERO_ERROR;
    UChar *result = NULL;
    UChar pattern[100];

    int32_t resultlength, resultLengthOut, i;
    double testArgs[] = { 100.0, 1.0, 0.0};
    str=(UChar*)malloc(sizeof(UChar) * 10);
    u_uastrcpy(str, "MyDisk");
    u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}");

    for(i=0; i<3; i++){
        resultlength=0; 
        resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str); 
        if(status==U_BUFFER_OVERFLOW_ERROR){ //check if output truncated
            status=U_ZERO_ERROR;
            resultlength=resultLengthOut+1;
            result=(UChar*)malloc(sizeof(UChar) * resultlength);
            u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);
        }
        printf("%s\n", austrdup(result) );  //austrdup( a function used to convert UChar* to char*)
        free(result);
    }
    return 0;
}
icu icu4c
1个回答
0
投票

austrdup不是官方的ICU方法。它仅由ICU中的测试使用,并在icu4c/source/test/cintltst/cintltst.h中定义并在icu4c/source/test/cintltst/cintltst.h中实现。基本上,它只是icu4c/source/test/cintltst/cintltst.c的包装。

© www.soinside.com 2019 - 2024. All rights reserved.