Categories: None [Edit]
u
U
U extends Ruby’s Unicode support. It provides a string class called
U::String with an interface that mimics that of the String class in Ruby 2.0,
but that can also be used from both Ruby 1.8. This interface also has more
complete Unicode support and never modifies the receiver. Thus, a U::String
is an immutable value object.
U comes with complete and very accurate documentation¹. The documentation can
realistically also be used as a reference to the Ruby String API and may
actually be preferable, as it’s a lot more explicit and complete than the
documentation that comes with Ruby.
¹ See http://disu.se/software/u-1.0/api/
§ Installation
Install u with
% gem install u
§ Usage
Usage is basically the following:
require 'u-1.0'
a = 'äbc'
a.upcase # ⇒ 'äBC'
a.u.upcase # ⇒ 'ÄBC'
That is, you require the library, then you invoke #u on a String. This’ll
give you a U::String that has much better Unicode support than a normal
String. It’s important to note that U only uses UTF-8, which means that #u
will try to #encode the String as such. This shouldn’t be an issue in most
cases, as UTF-8 is now more or less the universal encoding – and rightfully
so.
As U::Strings¹ are immutable value objects, there’s also a U::Buffer²
available for building U::Strings efficiently.
See the API³ for more complete usage information. The following sections
will only cover the extensions and differences that U::String exhibit from
Ruby’s built-in String class.
¹ See http://disu.se/software/u-1.0/api/U/String/
² See http://disu.se/software/u-1.0/api/U/Buffer/
³ See http://disu.se/software/u-1.0/api/
§ Unicode Properties
There are quite a few property-checking interrogators that let you check
if all characters in a U::String have the given Unicode property:
• #alnum?¹
• #alpha?²
• #assigned?³
• #case_ignorable?⁴
• #cased?⁵
• #c...
Total
Ranking: 77,690 of 183,107
Downloads: 10,829
Daily
Ranking: 35,920 of 183,092
Downloads: 3
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|
Depends on
Rank | Downloads | Name |
---|---|---|
224 | 158,681,269 | yard |
22,630 | 58,827 | inventory |
33,429 | 34,289 | lookout |
34,575 | 32,744 | inventory-rake |
34,879 | 32,346 | inventory-rake-tasks-yard |
51,549 | 19,282 | yard-heuristics |
61,713 | 15,140 | lookout-rake |
Owners
# | Gravatar | Handle |
---|---|---|
1 | now |