utf8proc 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/extconf.rb +2 -0
- data/ext/utf8proc_native.c +14516 -0
- data/lib/utf8proc.rb +112 -0
- metadata +46 -0
data/lib/utf8proc.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) 2006, FlexiGuided GmbH, Berlin, Germany
|
3
|
+
# Author: Jan Behrens <jan.behrens@flexiguided.de>
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are
|
8
|
+
# met:
|
9
|
+
#
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
# 3. Neither the name of the FlexiGuided GmbH nor the names of its
|
16
|
+
# contributors may be used to endorse or promote products derived from
|
17
|
+
# this software without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
23
|
+
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
24
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
25
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
26
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
27
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
#
|
31
|
+
##
|
32
|
+
|
33
|
+
|
34
|
+
##
|
35
|
+
# File name: ruby/utf8proc.rb
|
36
|
+
# Version: 1.0
|
37
|
+
# Last changed: 2006-09-17
|
38
|
+
#
|
39
|
+
# Description:
|
40
|
+
# Part of the ruby wrapper for libutf8proc, which is written in ruby.
|
41
|
+
##
|
42
|
+
|
43
|
+
|
44
|
+
require 'utf8proc_native'
|
45
|
+
|
46
|
+
|
47
|
+
module Utf8Proc
|
48
|
+
|
49
|
+
SpecialChars = {
|
50
|
+
:HT => "\x09",
|
51
|
+
:LF => "\x0A",
|
52
|
+
:VT => "\x0B",
|
53
|
+
:FF => "\x0C",
|
54
|
+
:CR => "\x0D",
|
55
|
+
:FS => "\x1C",
|
56
|
+
:GS => "\x1D",
|
57
|
+
:RS => "\x1E",
|
58
|
+
:US => "\x1F",
|
59
|
+
:LS => "\xE2\x80\xA8",
|
60
|
+
:PS => "\xE2\x80\xA9",
|
61
|
+
}
|
62
|
+
|
63
|
+
module StringExtensions
|
64
|
+
def utf8map(*option_array)
|
65
|
+
options = 0
|
66
|
+
option_array.each do |option|
|
67
|
+
flag = Utf8Proc::Options[option]
|
68
|
+
raise ArgumentError, "Unknown argument given to String#utf8map." unless
|
69
|
+
flag
|
70
|
+
options |= flag
|
71
|
+
end
|
72
|
+
return Utf8Proc::utf8map(self, options)
|
73
|
+
end
|
74
|
+
def utf8map!(*option_array)
|
75
|
+
self.replace(self.utf8map(*option_array))
|
76
|
+
end
|
77
|
+
def utf8nfd; utf8map( :stable, :decompose); end
|
78
|
+
def utf8nfd!; utf8map!(:stable, :decompose); end
|
79
|
+
def utf8nfc; utf8map( :stable, :compose); end
|
80
|
+
def utf8nfc!; utf8map!(:stable, :compose); end
|
81
|
+
def utf8nfkd; utf8map( :stable, :decompose, :compat); end
|
82
|
+
def utf8nfkd!; utf8map!(:stable, :decompose, :compat); end
|
83
|
+
def utf8nfkc; utf8map( :stable, :compose, :compat); end
|
84
|
+
def utf8nfkc!; utf8map!(:stable, :compose, :compat); end
|
85
|
+
def utf8chars
|
86
|
+
result = self.utf8map(:charbound).split("\377")
|
87
|
+
result.shift if result.first.empty?
|
88
|
+
result
|
89
|
+
end
|
90
|
+
def char_ary
|
91
|
+
# depecated, use String#utf8chars instead
|
92
|
+
utf8chars
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
module IntegerExtensions
|
97
|
+
def utf8
|
98
|
+
return Utf8Proc::utf8char(self)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
class String
|
106
|
+
include(Utf8Proc::StringExtensions)
|
107
|
+
end
|
108
|
+
|
109
|
+
class Integer
|
110
|
+
include(Utf8Proc::IntegerExtensions)
|
111
|
+
end
|
112
|
+
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: utf8proc
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2006-09-20 00:00:00 +00:00
|
8
|
+
summary: UTF-8 Unicode string processing
|
9
|
+
require_paths:
|
10
|
+
- lib/
|
11
|
+
email: jan.behrens@flexiguided.de
|
12
|
+
homepage: http://www.flexiguided.de/publications.utf8proc.en.html
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- Jan Behrens
|
30
|
+
files:
|
31
|
+
- lib/utf8proc.rb
|
32
|
+
- ext/utf8proc_native.c
|
33
|
+
test_files: []
|
34
|
+
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
extra_rdoc_files: []
|
38
|
+
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions:
|
42
|
+
- ext/extconf.rb
|
43
|
+
requirements: []
|
44
|
+
|
45
|
+
dependencies: []
|
46
|
+
|