Sha256: b9a8f3c396d6c83ef966a881212fb1d29c69b213e7ac1f89c7d77a42efa3d341
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
=begin Copyright © 2007 John Vorhauer Contact me at langa@vorhauer.de near 50°55'N+6°55'E. This file is part of Langa. Langa is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Langa is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Langa. If not, see <http://www.gnu.org/licenses/>. For a detailed functional description of Langa see README file =end =begin rdoc Extend class Array and class String to uniformly handle code conversion to and from unicode =end class String # Converts a string to an array of unicode values. # 'äöü'.to_unicode => [228, 246, 252] # 'äöü' as UTF-8 is equivalent to [195, 164, 195, 182, 195, 188] def to_unicode self.unpack('U*') end end class Array # Converts an array of unicodes values to an utf-8 coded string # [228, 246, 252].to_uft8 -> 'äöü' def to_utf8 self.pack('U*') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
langa-1.0.0 | lib/langa/utilities.rb |