utf8_proc 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +12 -2
- data/README.md +4 -0
- data/ext/utf8_proc/extconf.rb +3 -0
- data/ext/utf8_proc/utf8_proc.c +25 -13
- data/lib/utf8_proc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f0100ceec29ddf6573a113e96b40afc739d7584
|
4
|
+
data.tar.gz: 8698ee90244f05aec2754f3aaf1701a7a13cd8cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adae5ae7a317c87d0a75553161530152c26d2479c7b8849eeff5cf7109476ad0e9255e4e13bd039eea780173ea8bc1eb43beebbc2ef0658ca069b363d33eb0bc
|
7
|
+
data.tar.gz: 8429060afb0af89b5e2fb3ac2a5cc54220bf9ed5e164f611b871aaa1bb9399ef71f0a5511b6b14826d8260284d615ad6d41ab4c5761def775ba1cfcf0a2b0d2f
|
data/.travis.yml
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
|
1
|
+
dist: trusty
|
2
|
+
sudo: required
|
2
3
|
language: ruby
|
3
4
|
rvm:
|
4
5
|
- 2.4.0
|
5
|
-
|
6
|
+
- 2.3.3
|
7
|
+
- 2.2.6
|
8
|
+
- 2.1.10
|
9
|
+
- 2.0.0
|
10
|
+
before_install:
|
11
|
+
- wget -O utf8proc.zip https://github.com/JuliaLang/utf8proc/archive/v2.1.0.zip
|
12
|
+
- unzip utf8proc.zip
|
13
|
+
- pushd utf8proc* && sudo make install prefix=/usr && popd
|
14
|
+
- gem install bundler -v 1.14.4
|
15
|
+
script: bundle exec rake
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# UTF8Proc
|
2
2
|
|
3
|
+
[](https://travis-ci.org/nomoon/utf8_proc)
|
3
4
|
[](https://gemnasium.com/github.com/nomoon/utf8_proc)
|
4
5
|
[](https://badge.fury.io/rb/utf8_proc)
|
5
6
|
|
@@ -49,6 +50,9 @@ UTF8Proc.NFKC_CF(utf8_string)
|
|
49
50
|
|
50
51
|
# Second argument may be any of: [:nfc (default), :nfd, :nfkc, :nfkd, :nfkc_cf]
|
51
52
|
UTF8Proc.normalize(utf8_string, form = :nfc)
|
53
|
+
|
54
|
+
# Version string of loaded libutf8proc
|
55
|
+
UTF8Proc::LIBRARY_VERSION
|
52
56
|
```
|
53
57
|
|
54
58
|
## Contributing
|
data/ext/utf8_proc/extconf.rb
CHANGED
data/ext/utf8_proc/utf8_proc.c
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
|
2
2
|
#include "utf8_proc.h"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
ID NFC;
|
7
|
-
ID NFD;
|
8
|
-
ID NFKC;
|
9
|
-
ID NFKD;
|
10
|
-
ID NFKC_CF;
|
4
|
+
static rb_encoding *enc_utf8;
|
5
|
+
static rb_encoding *enc_usascii;
|
6
|
+
static ID NFC;
|
7
|
+
static ID NFD;
|
8
|
+
static ID NFKC;
|
9
|
+
static ID NFKD;
|
10
|
+
static ID NFKC_CF;
|
11
11
|
|
12
12
|
static inline void checkStrEncoding(VALUE *string) {
|
13
|
-
rb_encoding *enc
|
13
|
+
rb_encoding *enc;
|
14
|
+
enc = rb_enc_get(*string);
|
14
15
|
if (enc != enc_utf8 && enc != enc_usascii) {
|
15
16
|
rb_raise(rb_eEncodingError, "%s", "String must be in UTF-8 or US-ASCII encoding.");
|
16
17
|
}
|
@@ -19,10 +20,13 @@ static inline void checkStrEncoding(VALUE *string) {
|
|
19
20
|
static inline VALUE normInternal(VALUE string, utf8proc_option_t options) {
|
20
21
|
checkStrEncoding(&string);
|
21
22
|
utf8proc_uint8_t *retval;
|
22
|
-
utf8proc_ssize_t retlen
|
23
|
-
|
23
|
+
utf8proc_ssize_t retlen;
|
24
|
+
retlen = utf8proc_map(
|
25
|
+
(unsigned char *) StringValuePtr(string), RSTRING_LEN(string), &retval, options
|
26
|
+
);
|
24
27
|
|
25
|
-
VALUE new_str
|
28
|
+
VALUE new_str;
|
29
|
+
new_str = rb_enc_str_new((char *) retval, retlen, rb_utf8_encoding());
|
26
30
|
free(retval);
|
27
31
|
|
28
32
|
return new_str;
|
@@ -59,7 +63,8 @@ VALUE norm(int argc, VALUE* argv, VALUE self){
|
|
59
63
|
return toNFC(self, string);
|
60
64
|
}
|
61
65
|
|
62
|
-
ID s_form
|
66
|
+
ID s_form;
|
67
|
+
s_form = SYM2ID(form);
|
63
68
|
if (s_form == NFC) {
|
64
69
|
return toNFC(self, string);
|
65
70
|
}else if(s_form == NFD) {
|
@@ -78,7 +83,8 @@ VALUE norm(int argc, VALUE* argv, VALUE self){
|
|
78
83
|
}
|
79
84
|
|
80
85
|
void Init_utf8_proc(void) {
|
81
|
-
VALUE rb_mBase
|
86
|
+
VALUE rb_mBase;
|
87
|
+
rb_mBase = rb_define_module("UTF8Proc");
|
82
88
|
|
83
89
|
enc_utf8 = rb_utf8_encoding();
|
84
90
|
enc_usascii = rb_usascii_encoding();
|
@@ -88,6 +94,12 @@ void Init_utf8_proc(void) {
|
|
88
94
|
NFKD = rb_intern("nfkd");
|
89
95
|
NFKC_CF = rb_intern("nfkc_cf");
|
90
96
|
|
97
|
+
const char *libVersion;
|
98
|
+
libVersion = utf8proc_version();
|
99
|
+
rb_define_const(rb_mBase, "LIBRARY_VERSION", rb_str_freeze(
|
100
|
+
rb_enc_str_new(libVersion, strlen(libVersion), enc_utf8)
|
101
|
+
));
|
102
|
+
|
91
103
|
rb_define_singleton_method(rb_mBase, "NFC", toNFC, 1);
|
92
104
|
rb_define_singleton_method(rb_mBase, "NFD", toNFD, 1);
|
93
105
|
rb_define_singleton_method(rb_mBase, "NFKC", toNFKC, 1);
|
data/lib/utf8_proc/version.rb
CHANGED