[squeak-dev] Unicode

Tobias Pape Das.Linux at gmx.de
Sun Sep 6 19:00:14 UTC 2020


> On 06.09.2020, at 20:40, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> 
> On Sun, 6 Sep 2020, Tobias Pape wrote:
> 
>> 
>>> On 06.09.2020, at 19:15, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>>> Hi Christoph, Hi All,
>>>> On Mar 17, 2020, at 3:51 PM, Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:
>>>> Hi all! :-)
>>>> After some recent fun with the Unicode class, I found out that its data is quite out of date (for example, the comments do not even "know" that code points can be longer than 4 bytes. Younger characters such as 😺❤🤓 are not categorized correctly, etc. ...). Luckily, there is already some logic to fetch the latest data from www.unicode.org. I'm currently reworking this logic because it's not completely automated yet and has some slips, but so long, I have one general question for you:
>>> And consequently I have a couple of questions for you. In the Spur VM Characters are immediate (they are like SmallInteger and exist in oops (object-oriented pointers) as tagged values).  In the 32-bit variant Characters are 30-bit unsigned integers.  In the 64-bit variant they are also 30-bit unsigned integers, but could easily be extended to be up to 61-bit unsigned integers.
>>> Q1, can you arrange that the Unicode support does not break in initialization on the 32-bit variant?  It may be that the 32-bit variant cannot represent code points beyond 30 bits in size, but we should try to ensure that initialization still runs to completion even if it fails to initialize information relating to code points beyond 30 bits in size.
>>> Q2, how many bits should the 64-bit variant VM support for immediate Characters?
>> 
>> Unicode has a max value of 0x10FFFF. That makes 21 bit. So no worries there.
>> 
>> We should just not forget the leading-char stuff (Yoshiki, Andreas,...)
> 
> AFAIU the leading char only makes sense when you have multiple CJK(V?) languages in use at the same time. In other cases Unicode (leadingChar = 0) is perfectly fine.
> IIRC there are 22 bits available for the codePoint and 8 for the leadingChar, so we're still good: all unicode characters fit.
> 
> 

\o/ hooray!

> Levente
> 
>> 
>> 
>> BEst regards
>> 	-Tobias
>> 
>>> Then something to consider is that it is conceptually possible to support something like WideCharacter, which would represent code points outside of the immediate Character range on the 32-bit variant, analogous to LargePositiveInteger beyond SmallInteger maxVal.  This can be made to work seamlessly, just as it does currently with integers, and with Floats where SmallFloat64 is only used on 64-bits.
>>> It has implications in a few parts of the system:
>>> - failure code for WideString (VeryWideString?) at:[put:] primitives that would have to manage overflow into/access from WideCharacter instances
>>> - ImageSegment and other (un)pickling systems that need to convert to/from a bit-specific “wire” protocol/representation
>>> - 32-bit <=> 64-bit image conversion All this is easily doable (because we have models of doing it for Float and Integer general instances).  But we need good specifications so we can implement the right thing from the get-go.
>>>> At the moment, we have 30 class variables each for one Unicode category number. These class vars map in alphabetical order to the integers from 0 to: 29. Is this tedious structure really necessary? For different purposes, I would like to get the category name of a specific code point from a client. The current design makes this impossible without writing additional mappings.
>>>> Tl;dr: I would like to propose to drop these class variables and use Symbols instead. They are comparable like integers, and as they are flyweights, this should not be a performance issue either. Of course, #generalCategoryOf: will have to keep returning numbers, but we could deprecate it and use a new #generalTagOf: in the future. Furthermore, this would also allow us to deal with later added category names (though I don't know whether this will ever happen).
>>>> Examples:
>>>> Unicode generalTagOf: $a asUnicode. "#Ll"
>>>> Unicode class >> isLetterCode: charCode
>>>>  ^ (self generalTagOf: charCode) first = $L
>>>> Unicode class >> isAlphaNumericCode: charCode
>>>>  | tag|
>>>>  ^ (tag := self generalCategoryOf: charCode) first = $L
>>>>        or: [tag = #Nd]
>>>> How do you think about this proposal? Please let me know and I will go ahead! :D
>>>> Best,
>>>> Christoph
>>> Best, Eliot
>>> _,,,^..^,,,_ (phone)




More information about the Squeak-dev mailing list