为 jruby 1.8.2(本机实现)寻找具有规范化器(NFD、NFKD、NFC、NFKC)的 gem

发布于 2024-11-29 17:12:52 字数 67 浏览 3 评论 0原文

是否有一个本地gem(因此它可以用于jruby 1.8.2)实现UTF8规范化器(NFD,NFKD,NFC,NFKC)?

Is there a native gem (so it can be used for jruby 1.8.2) which implements UTF8 normalizers (NFD, NFKD, NFC, NFKC)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荭秂 2024-12-06 17:12:52

Ruby v1.8 在 Unicode 上确实很不稳定。我发现 v1.9 是进行正常处理的最小 Ruby 版本。即便如此,unicode_utils gem for v1.9.1 for better 绝对是不可或缺的。它具有完整的案例映射和标准化功能等功能。你确实需要它。

不幸的是,它不包含排序规则,因此您无法进行字母排序 Ruby 可以像 Perl 或语言一样访问 ICU 库。排序规则是最难正确完成的,因此缺少它也就不足为奇了。但这很重要,因为它几乎是我们对文本所做的一切的基础。这不仅仅是排序;这是关于简单的字符串比较。大多数人没有意识到这一点。

我在我的 第三篇文章中讨论了 Ruby 的 Unicode 支持以及如何让您的生活更轻松几周前的 OSCON 谈话。我承认我放弃了 Ruby v1.8;实在是太令人沮丧了。

这并不是对 Ruby 的批评,因为对于当今大多数不是最新版本的语言来说,同样的事情也可以说。

  • 除非您运行的是 v1.9,否则您不会对 Ruby 和 Unicode 感到满意。
  • 如果您没有运行具有广泛构建的 Python v3(最好是 v3.2 或可能 v3.3),那么您会对带有 Unicode 的 Python 感到不满意。
  • 如果您没有运行 Java v1.7,您将会对使用 Unicode 的 Java 感到不满意 — 甚至可能会不满意。 :(
  • 如果您没有运行 Perl v5.14 或更高版本,那么您可能会对带有 Unicode 的 Perl 感到不满意。

因此,这四种语言的情况与 PHP、Javascript 和 Go 的情况完全不同。对于后者三种语言,你运行什么版本并不重要,因为

  • 对于前两种语言,你总是会对它们的 Unicode 支持不满意,这真的很糟糕,因为使用它们的人几乎永远无法切换到。一种真正的语言具有真正的 Unicode 支持。
  • 而使用 Go,你永远不会对其 Unicode 支持感到不满意 - 除非你很着急:规范化模块已经非常接近准备就绪,并且已经发布了。 module 正在开发中,但是确实要困难得多。

您是否有任何可能的方法来使用 Ruby v1.9?

Ruby v1.8 is really flaky on Unicode. I find v1.9 the minimal Ruby version for sane processing. Even then, the unicode_utils gem for v1.9.1 for better is absolutely indispensable. It has things like full casemapping and normalization functions. You really do need it.

Unfortunately, it doesn’t include collation, so you can’t do alphabetic sorts in Ruby the way you can in Perl or languages with access to the ICU libraries. Collation is the hardest to get right so it is not surprising that it is missing. But it is critical because it underlies nearly everything we ever do with text. It’s not just about sorting; it’s about simple string comparisons. Most people don’t realize this.

I talk about Ruby’s Unicode support and what you can do to make your life easier there a little in my third OSCON talk from a couple weeks ago. I confess that I gave up on Ruby v1.8; it was just too too frustrating.

That’s not a knock against Ruby, because the same thing can be said for most languages today that aren’t the latest versions.

  • You will not be happy with Ruby and Unicode unless you’re running v1.9.
  • If you aren’t running Python v3 (and preferably v3.2 or probably v3.3) with a wide build, you will be unhappy in Python with Unicode.
  • If you aren’t running Java v1.7, you will be unhappy in Java with Unicode — and maybe even then. :(
  • If you aren’t running Perl v5.14 or better, you will be arguably unhappy in Perl with Unicode.

The situation with those four therefore is quite unlike the one(s) with PHP, Javascript, and Go. With those latter three languages, it doesn’t matter what version you run, because

  • With the first two you will always be unhappy with their Unicode support. This is really really terrible because the people using them can almost never switch to a real language with real Unicode support. The niche is too special-purpose.
  • Whereas with Go you will never be unhappy with its Unicode support — unless you’re in a hurry: the normalization module is very close to ready and be out already, while the collation module is being worked on but it really is a great deal harder.

Is there any possible way for you to use Ruby v1.9?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文