Comments (5)
okay, after studying UTS#10 (UCA) for a few hours, I have determined that the sort keys are 16-bit ints, not 8-bit ints.
I'm still confused over endian-ness issues, with regard to how to turn the sort keys into a string having the desired collation properties. Researching/thinking on it.
from twitter-cldr-rb.
I believe collation elements can be expressed in hex, so it stands to reason the sort keys can be as well. Remember that sort keys don't have anything to do with character representation, so encoding them as text won't be that useful (and will likely generate some pretty funky characters all over the Unicode spectrum). Have you considered storing the sort key in hex? Two hex strings can be compared easily, and if that doesn't work, you could always consider converting them back into a byte array:
[39, 61, 51, 1].map { |i| i.to_s(16).rjust(2, "0") }.join # => 273d3301
And back again:
"273d3301".chars.each_slice(2).map { |s| s.join.to_i(16) } # => [39, 61, 51, 1]
from twitter-cldr-rb.
Thanks! Hmm, if converted to hex like that, are the output strings still byte-order comparable with desired collation? If so, that might make a lot of sense. I just need a single binary value that can be stored in an external system, and compared for proper collation. Thanks for your tips!
from twitter-cldr-rb.
Unless I'm missing something, you should be able to compare two hex-encoded sort keys. The hex digits 0-9 and a-z are conveniently in ascending ASCII order. Here's an easier way to convert (with pack this time):
[39, 61, 51, 1].pack("c*").unpack("H*") # => ["273d3301"]
from twitter-cldr-rb.
thanks you for your advice!
from twitter-cldr-rb.
Related Issues (20)
- CLDR 35 Dev Branch HOT 2
- Formatting a full datetime with a time zone gives current time timezone (PST instead of PDT) HOT 4
- Incorrect list formatter behaviour HOT 2
- Exception when using hyphenate HOT 1
- Incorrect LikelySubtags.locale_for behaviour HOT 1
- Incorrect ListFormatter behaviour HOT 6
- Weekday names `:wide` format is the same as `:abbreviated` HOT 5
- Ruby 3.1.0 with Psych 4 forces YAML.safe_load and throws Psych::DisallowedClass HOT 1
- Month names :narrow format returns array of digits rather than the first letter of each month HOT 3
- Ruby 2.7+ compatibility issue/question HOT 1
- Warning when running Sorbet HOT 2
- Why use :one instead of :name HOT 1
- Remove lone release HOT 1
- Missing titlecase and/or uppercase mappings? HOT 1
- Add support for yMMMMd (October 7, 2022) HOT 2
- `format: :long` breaks when combined with currency formatting HOT 4
- Breaking by word a string containing Japanese and Latin characters HOT 3
- Contributor access revoked HOT 1
- Wrong language name is returned for Norwegian Nynorsk (nn) HOT 1
- Unicode, ICU, CLDR update HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitter-cldr-rb.