Ruby 是否支持 unicode 以及它是如何工作的? [英] Does Ruby support unicode and how does it work?

查看:28
本文介绍了Ruby 是否支持 unicode 以及它是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习 Ruby(最终转向 RoR),但我刚刚被告知 Ruby 不支持 unicode.这是真的吗?Ruby 程序员如何支持 unicode?

I am just starting to learn Ruby (to eventually move to RoR), but I was just told that Ruby does not support unicode. Is it true? How do Ruby programmers go about supporting unicode?

推荐答案

您所听到的已经过时并且(仅部分)适用于 Ruby 1.8 或之前版本.Ruby 最新稳定版(1.9),支持不少于95 种不同的字符编码(以我的系统为例).这包括几乎所有已知的 Unicode 转换格式,包括 UTF-8.

What you heard is outdated and applies (only partially) to Ruby 1.8 or before. The latest stable version of Ruby (1.9), supports no less than 95 different character encodings (counted on my system just now). This includes pretty much all known Unicode Transformation Formats, including UTF-8.

以前的稳定版 Ruby (1.8) 部分支持 UTF-8.

The previous stable version of Ruby (1.8) has partial support for UTF-8.

如果您使用 Rails,它会为您处理默认的 UTF-8 编码.如果您只需要 UTF-8 编码意识,Rails 将适合您无论您运行 Ruby 1.9 还是 Ruby 1.8.如果您有非常具体的字符编码要求,则应针对 Ruby 1.9.

If you use Rails, it takes care of default UTF-8 encoding for you. If all you need is UTF-8 encoding awareness, Rails will work for you no matter if you run Ruby 1.9 or Ruby 1.8. If you have very specific character encoding requirements, you should aim for Ruby 1.9.

如果您真的感兴趣,这里有一个系列文章Ruby 1.8 中的编码问题以及它们是如何解决的,最终在 Ruby 1.9 中得到解决.Rails 仍然包含针对 Ruby 1.8 中许多常见缺陷的变通方法.

If you're really interested, here is a series of articles describing the encoding issues in Ruby 1.8 and how they were worked around, and eventually solved in Ruby 1.9. Rails still includes workarounds for many common flaws in Ruby 1.8.

这篇关于Ruby 是否支持 unicode 以及它是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆