Skip to content

文字列の組み込み関数の一部が書記素クラスタ単位に対応していない #1034

Description

@poppingmoon

👍🏽 のような一文字を作るコードポイントの数が1より大きい文字が含まれる文字列について、一部の組み込み関数が正しく動作しない

let str1 = '👍🏽🍆🌮'
let str2 = 'abc'
let str3 = 'あいう'

<: str1.index_of('👍🏽', -3)  // -1
<: str2.index_of('a', -3)  // 0
<: str3.index_of('あ', -3)  // 0

<: str1.incl('👍')  // true
<: str1.incl('🏽')  // true

<: str1.starts_with('👍🏽', -3)  // false
<: str2.starts_with('a', -3)  // true
<: str3.starts_with('あ', -3)  // true

<: str1.ends_with('👍🏽', -2)  // false
<: str2.ends_with('a', -2)  // true
<: str3.ends_with('あ', -2)  // true

<: str1.pad_start(4, '0')  // 👍🏽🍆🌮
<: str2.pad_start(4, '0')  // 0abc
<: str3.pad_start(4, '0')  // 0あいう


<: str1.pad_end(4, '0')  // 👍🏽🍆🌮
<: str2.pad_end(4, '0')  // abc0
<: str3.pad_end(4, '0')  // あいう0

Playground

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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