gpt4 book ai didi

objective-c - 返回带有代码点的 Unicode 名称

转载 作者:行者123 更新时间:2023-12-03 16:46:03 25 4
gpt4 key购买 nike

我知道如何从代码点返回 Unicode 字符。那不是我所追求的。我想知道的是如何返回与特定代码点关联的名称。例如,🍀 的代码点是 1F340。它的名字叫四叶草。我们是否可以返回该名称及其代码点?我读过大约 100 个涉及 Unicode 的主题。但我没有看到有人讨论我的问题。我希望这是可能的。

感谢您的帮助。

最佳答案

您是否考虑过 ICU library ?它提供以下 C API:http://icu-project.org/apiref/icu4c/uchar_8h.html#aa488f2a373998c7decb0ecd3e3552079

int32_t u_charName(
UChar32 code,
UCharNameChoice nameChoice,
char* buffer,
int32_t bufferLength,
UErrorCode* pErrorCode)

Retrieve the name of a Unicode character.

Depending on nameChoice, the character name written into the buffer is the "modern" name or the name that was defined in Unicode version 1.0. The name contains only "invariant" characters like A-Z, 0-9, space, and '-'. Unicode 1.0 names are only retrieved if they are different from the modern names and if the data file contains the data for them. gennames may or may not be called with a command line option to include 1.0 names in unames.dat.

Parameters

code The character (code point) for which to get the name. It must be 0<=code<=0x10ffff.

nameChoice Selector for which name to get.

buffer Destination address for copying the name. The name will always be zero-terminated. If there is no name, then the buffer will be set to the empty string.

bufferLength ==sizeof(buffer)

pErrorCode Pointer to a UErrorCode variable; check for U_SUCCESS() after u_charName() returns.

返回

The length of the name, or 0 if there is no name for this character. If the bufferLength is less than or equal to the length, then the buffer contains the truncated name and the returned length indicates the full length of the name. The length does not include the zero-termination.

关于objective-c - 返回带有代码点的 Unicode 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25345990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com