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,575 of 183,477
Downloads: 10,922
Daily
Ranking: 63,432 of 183,470
Downloads: 0
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 | 160,939,746 | yard |
22,686 | 59,037 | inventory |
33,530 | 34,417 | lookout |
34,658 | 32,880 | inventory-rake |
34,988 | 32,467 | inventory-rake-tasks-yard |
51,619 | 19,375 | yard-heuristics |
61,849 | 15,204 | lookout-rake |
Owners
# | Gravatar | Handle |
---|---|---|
1 | now |