Re: String complements

> 
> Doesn’t blindly subtracting the code point for 0x110000 run the risk of producing a non-Unicode character? I think the original code point would have to be in…checks notes…plane 16, so fairly unlikely, but still…
> 
>   

I think it's producing a binary value rather than a string, so that would be OK.

Interestingly in the XSLT compiler for SaxonJS we use a similar technique for sorting stylesheet modules into order of import precedence. If I recall correctly we allocate each import a letter starting with a notional Z (actually the last letter in a very large alphabet) and working downwards, so for the example in §3.11.3 of the spec where

    • stylesheet module A imports stylesheet modules B and C in that order;
    • stylesheet module B imports stylesheet module D;
    • stylesheet module C imports stylesheet module E.

The keys we allocate are

A = Z
B = ZZ
C = ZY
D = ZZZ
E = ZYZ

so when you sort these ascending as strings, you get the order of precedence, highest first: A, C, E, B, D.

Michael Kay
Saxonica

Received on Friday, 15 March 2024 17:59:39 UTC