Uh oh!
There was an error while loading. Please reload this page.
gh-74902: Add Unicode Grapheme Cluster Break algorithm - #143076
Conversation
Add the unicodedata.iter_graphemes() function to iterate over grapheme clusters according to rules defined in Unicode Standard Annex python#29. Add unicodedata.grapheme_cluster_break(), unicodedata.indic_conjunct_break() and unicodedata.extended_pictographic() functions to get the properties of the character which are related to the above algorithm. Co-authored-by: Guillaume "Vermeille" Sanchez <guillaume.v.sanchez@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| ``False`` otherwise. | ||
| .. versionadded:: next | ||
There was a problem hiding this comment.
The order of functions in this file doesn’t seem to be alphabetical or topical.
I think another ticket should be created to add a quick links table at the top.
There was a problem hiding this comment.
Or we can split it on sections by type and order alphabetically inside a section.
| .. data:: ucd_3_2_0 | ||
| This is an object that has the same methods as the entire module, but uses the | ||
| This is an object that has most of the methods of the entire module, but uses the |
There was a problem hiding this comment.
This sentence is not fully right, but I can’t find the right suggestion with both «most of» and «same as».
merwok
commented
Dec 23, 2025
These functions help compute width? |
serhiy-storchaka
commented
Dec 23, 2025
At least two implementations (in Perl's Unicode::GCString and builtin in C++) use graphemes. Naive implementation in C's |
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
merwok
commented
Dec 23, 2025
Sorry if my question was not clear. |
serhiy-storchaka
commented
Dec 23, 2025
Yes, I think that |
Uh oh!
There was an error while loading. Please reload this page.
| self.assertEqual(chunks.pop(), '', line) | ||
| input = ''.join(chunks) | ||
| with self.subTest(line): | ||
| result = list(unicodedata.iter_graphemes(input)) |
There was a problem hiding this comment.
Did you mean to use the passed ucd argument?
| result=list(unicodedata.iter_graphemes(input)) | |
| result=list(ucd.iter_graphemes(input)) |
| self.assertEqual([x.start for x in result], breaks[:-1], comment) | ||
| self.assertEqual([x.end for x in result], breaks[1:], comment) | ||
| for i in range(1, len(breaks) - 1): | ||
| result = list(unicodedata.iter_graphemes(input, breaks[i])) |
There was a problem hiding this comment.
| result=list(unicodedata.iter_graphemes(input, breaks[i])) | |
| result=list(ucd.iter_graphemes(input, breaks[i])) |
Continues above.
There was a problem hiding this comment.
No, it is module-only function.
| } | ||
| /* XXX Add doc strings. */ |
There was a problem hiding this comment.
The above functions already have docstrings?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| hdr = testfile.readline() | ||
| return unicodedata.unidata_version in hdr | ||
| @requires_resource('network') |
There was a problem hiding this comment.
Should it not be urlfetch resource?
There was a problem hiding this comment.
Maybe. The other test (for normalization) uses the network resource).
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot
commented
Jan 14, 2026
|
bedevere-bot
commented
Jan 14, 2026
|
bedevere-bot
commented
Jan 14, 2026
|
…H-143076) Add the unicodedata.iter_graphemes() function to iterate over grapheme clusters according to rules defined in Unicode Standard Annex python#29. Add unicodedata.grapheme_cluster_break(), unicodedata.indic_conjunct_break() and unicodedata.extended_pictographic() functions to get the properties of the character which are related to the above algorithm. Co-authored-by: Guillaume "Vermeille" Sanchez <guillaume.v.sanchez@gmail.com>
…ythonGH-143076) Add the unicodedata.iter_graphemes() function to iterate over grapheme clusters according to rules defined in Unicode Standard Annex #29. Add unicodedata.grapheme_cluster_break(), unicodedata.indic_conjunct_break() and unicodedata.extended_pictographic() functions to get the properties of the character which are related to the above algorithm. (cherry picked from commit bab1d7a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Guillaume "Vermeille" Sanchez <guillaume.v.sanchez@gmail.com>
GH-148247 is a backport of this pull request to the 3.14 branch. |
Add the unicodedata.iter_graphemes() function to iterate over grapheme clusters according to rules defined in Unicode Standard Annex
#29.Add unicodedata.grapheme_cluster_break(), unicodedata.indic_conjunct_break() and unicodedata.extended_pictographic() functions to get the properties of the character which are related to the above algorithm.