compact_enc_det 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61c2647510e32fcb25ebbd1865fca25d6eeee88179271a31d398abce27ded9f0
|
4
|
+
data.tar.gz: d48c052f4c8e9f741e51ed6eb29d6cbd63b691067923cbcd4b9662633311daa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d1efb9b630020650e8fdc242f50295c3c71014a6a4e11f5a9747c4cfcd754e8921bfc30ce1e5fa60832b1a227173953082ab05263af2c121a22848ef545671d
|
7
|
+
data.tar.gz: a5fe81c1c59b87cdfaffa7c2cbb827dca231aff525abe286d2d671693898e41d10f3a915df2aee365224b8478ad3d5658cda3b1ac901f0d17ed6d09bc428868a
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Now you can detect the encoding via the `CompactEncDet.detect_encoding`,
|
|
31
31
|
which is a thin wrapper around `CompactEncDet::DetectEncoding` and `MimeEncodingName` functions from the C++ library.
|
32
32
|
|
33
33
|
> ```ruby
|
34
|
-
> file = File.read("unknown-encoding.txt")
|
34
|
+
> file = File.read("unknown-encoding.txt", mode: "rb")
|
35
35
|
> result = CompactEncDet.detect_encoding(file)
|
36
36
|
> result.encoding
|
37
37
|
> # => #<Encoding:Windows-1250>
|
@@ -56,9 +56,12 @@ static VALUE detect_encoding(int argc, VALUE *argv, VALUE self)
|
|
56
56
|
&corpus_type,
|
57
57
|
&ignore_7bit_mail_encodings);
|
58
58
|
|
59
|
+
// Ensure the text argument is a Ruby string
|
60
|
+
Check_Type(text, T_STRING);
|
61
|
+
|
59
62
|
// Convert the Ruby arguments to C++ types
|
60
|
-
const char* c_text =
|
61
|
-
const int c_text_length = NIL_P(text_length) ?
|
63
|
+
const char* c_text = RSTRING_PTR(text);
|
64
|
+
const int c_text_length = NIL_P(text_length) ? RSTRING_LEN(text) : NUM2INT(text_length);
|
62
65
|
|
63
66
|
// Declare the output variables
|
64
67
|
int bytes_consumed;
|