我如何使用ICU4C正常化的字符串?

编程入门 行业动态 更新时间:2024-10-28 10:34:16
本文介绍了我如何使用ICU4C正常化的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我觉得ICU文档有点挑战性。

I find the ICU docs somewhat challenging.

我的问题是:我如何使用ICU4C正常化字符串

My question is: How do I normalize a string using ICU4C?

我看着unorm2_normalize,但如果缓冲区不够大呢?我怎么会知道之前呢?当然,我想正常化整个字符串。

I'm looking at unorm2_normalize, but what if the buffer isn't large enough? How would I know this before? Naturally, I want to normalize the entire string.

谢谢! :>

P.S。下面是该函数的API文档:的icu-project/apiref/icu4c/unorm2_8h.html#a0a596802db767da410b4b04cb75cbc53

P.S. Here is the API doc on that function: icu-project/apiref/icu4c/unorm2_8h.html#a0a596802db767da410b4b04cb75cbc53

推荐答案

您得到一个错误code从PERROR code参数所有这些函数调用回来。这是你如何把这种功能:

You get a error code back from all these function call in the pErrorCode parameter. This is how you call such a function:

UErrorCode error = U_ZERO_ERROR; unorm2_normalize( ... &error ); .... if( !U_SUCCESS( error ) ) { // handle error... }

下面是错误codeS:的icu-project/apiref/icu4c/utypes_8h.html#a3343c1c8a8377277046774691c98d78c

Here are the error codes: icu-project/apiref/icu4c/utypes_8h.html#a3343c1c8a8377277046774691c98d78c

在你的情况,你可能想要做这样的事情:

In your case you might want to do something like this:

if( error == U_STRING_NOT_TERMINATED_WARNING || error == U_BUFFER_OVERFLOW_ERROR ) { // enlarge the buffer... }

更多推荐

我如何使用ICU4C正常化的字符串?

本文发布于:2023-10-17 06:30:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500049.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   如何使用   ICU4C

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!