Skip to content

TextEmojiProcessor】GetCharacterNum 对 emoji 肤色修饰符序列后的普通字符少计 #3

Description

@yingying9025123-code

问题描述

TextEmojiProcessor::GetCharacterNum(const std::u16string&) 在 emoji 肤色修饰符序列(emoji modifier sequence)后紧跟普
通 ASCII 字符时,返回的字符数比 Unicode grapheme cluster 数少 1。

这会使文本组件的字符计数与用户实际感知的字符数不一致。

影响版本

当前分支:

OpenHarmony-6.1-Release
commit: 3e110704b77

复现代码

  #include "core/text/text_emoji_processor.h"

  using namespace OHOS::Ace;

  std::u16string content = u"aaaaaaaa👍🏽0";                                                                                 ``
  int32_t count = TextEmojiProcessor::GetCharacterNum(content);

实际结果

  count == 9

期望结果

  count == 10

影响

如果 GetCharacterNum 用于文本输入框的字符数统计、maxLength 限制、光标移动或删除边界计算,可能出现:

  • 用户看到的字符数与组件统计值不一致;
  • maxLength 判定提前或滞后;
  • emoji modifier sequence 后的普通字符在编辑场景中被错误计数。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions