From: "Mrlaura (QUANG NGUYEN) via ruby-core" Date: 2026-10-29T07:25:42+00:00 Subject: [ruby-core:127275] [Ruby Feature#13241] Method(s) to access Unicode properties for characters/strings Issue #13241 has been updated by Mrlaura (QUANG NGUYEN). One thing I didn't see discussed much is `Script_Extensions`. `Script` gives a single value for each code point, but `Script_Extensions` can return a set of scripts. The Japanese prolonged sound mark `���` is a useful example: its Script value is Common, while its Script_Extensions includes Hiragana and Katakana. I wonder if it would make sense to expose those as two separate properties, rather than having a single `unicode_script` method. That could be useful for mixed-script text processing without making the API too complicated. I maintain a short technical reference on the distinction, in case it's useful: "Unicode Script and Script_Extensions":https://letrasdiferentess.github.io/us/unicode-script-properties/ ---------------------------------------- Feature #13241: Method(s) to access Unicode properties for characters/strings https://bugs.ruby-lang.org/issues/13241#change-119695 * Author: duerst (Martin D��rst) * Status: Open ---------------------------------------- [This is currently an exploratory proposal.] Onigmo allows Unicode properties in regular expressions. With this, it's e.g. possible to check whether a string contains some Hiragana: ``` "ABC ��� DEF" =~ /\p{hiragana}/ ``` However, it is currently impossible to ask for e.g. the script of a character. I propose to add a method (or some methods) to String to be able to get such properties. Various (to some extent conflicting) examples: ``` "A������".script => :latin # returns script of first character only "A������".script => [:latin, :hiragana, :katakana] # returns array of property values "A������".property(:script) => :latin # returns specified property of first character only "A������".property(:script) => [:latin, :hiragana, :katakana] # returns array of specified properties' values "A������".properties([:script, :general_category]) => [[:latin, :Lu], [:hiragana, :Lo], [:katakana, :Lo]] # returns arrays of property values, one array per character ``` The interface is still in flux, comments welcome! Implementation depends on #13240. In Python, such functionality (however, quite limited in property coverage, and not directly on String) is available in the standard library (see https://docs.python.org/3/library/unicodedata.html). -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/