Skip to content

Commit 86ab091

Browse files
authored
Copy kconv from rbs/stdlib (#989)
kconv is a bundled gem and should be removed from the rbs repository. Since kconv is managed by the nkf gem, it will be managed in the nkf directory.
1 parent 2a5d205 commit 86ab091

File tree

2 files changed

+170
-0
lines changed

2 files changed

+170
-0
lines changed

gems/nkf/0.2/_test/test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55

66
NKF.guess("str")
77
NKF.nkf("-w", "str")
8+
9+
require "kconv"
10+
11+
Kconv.guess("str")

gems/nkf/0.2/kconv.rbs

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
2+
# Kanji Converter for Ruby.
3+
#
4+
module Kconv
5+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
6+
# ASCII
7+
#
8+
ASCII: Encoding
9+
10+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
11+
# Auto-Detect
12+
#
13+
AUTO: nil
14+
15+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
16+
# BINARY
17+
#
18+
BINARY: Encoding
19+
20+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
21+
# EUC-JP
22+
#
23+
EUC: Encoding
24+
25+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
26+
# ISO-2022-JP
27+
#
28+
JIS: Encoding
29+
30+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
31+
# NOCONV
32+
#
33+
NOCONV: nil
34+
35+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
36+
# Shift_JIS
37+
#
38+
SJIS: Encoding
39+
40+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
41+
# UNKNOWN
42+
#
43+
UNKNOWN: nil
44+
45+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
46+
# UTF-16
47+
#
48+
UTF16: Encoding
49+
50+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
51+
# UTF-32
52+
#
53+
UTF32: Encoding
54+
55+
# <!-- rdoc-file=ext/nkf/lib/kconv.rb -->
56+
# UTF-8
57+
#
58+
UTF8: Encoding
59+
60+
# <!--
61+
# rdoc-file=ext/nkf/lib/kconv.rb
62+
# - Kconv.guess(str) => encoding
63+
# -->
64+
# Guess input encoding by NKF.guess
65+
#
66+
def self.guess: (String str) -> Encoding
67+
68+
# <!--
69+
# rdoc-file=ext/nkf/lib/kconv.rb
70+
# - Kconv.iseuc(str) => true or false
71+
# -->
72+
# Returns whether input encoding is EUC-JP or not.
73+
#
74+
# **Note** don't expect this return value is MatchData.
75+
#
76+
def self.iseuc: (String str) -> bool
77+
78+
# <!--
79+
# rdoc-file=ext/nkf/lib/kconv.rb
80+
# - Kconv.isjis(str) => true or false
81+
# -->
82+
# Returns whether input encoding is ISO-2022-JP or not.
83+
#
84+
def self.isjis: (String str) -> bool
85+
86+
# <!--
87+
# rdoc-file=ext/nkf/lib/kconv.rb
88+
# - Kconv.issjis(str) => true or false
89+
# -->
90+
# Returns whether input encoding is Shift_JIS or not.
91+
#
92+
def self.issjis: (String str) -> bool
93+
94+
# <!--
95+
# rdoc-file=ext/nkf/lib/kconv.rb
96+
# - Kconv.isutf8(str) => true or false
97+
# -->
98+
# Returns whether input encoding is UTF-8 or not.
99+
#
100+
def self.isutf8: (String str) -> bool
101+
102+
# <!--
103+
# rdoc-file=ext/nkf/lib/kconv.rb
104+
# - Kconv.kconv(str, to_enc, from_enc=nil)
105+
# -->
106+
# Convert `str` to `to_enc`. `to_enc` and `from_enc` are given as constants of
107+
# Kconv or Encoding objects.
108+
#
109+
def self.kconv: (String str, Encoding? out_code, ?Encoding? in_code) -> String
110+
111+
# <!--
112+
# rdoc-file=ext/nkf/lib/kconv.rb
113+
# - Kconv.toeuc(str) => string
114+
# -->
115+
# Convert `str` to EUC-JP
116+
#
117+
def self.toeuc: (String str) -> String
118+
119+
# <!--
120+
# rdoc-file=ext/nkf/lib/kconv.rb
121+
# - Kconv.tojis(str) => string
122+
# -->
123+
# Convert `str` to ISO-2022-JP
124+
#
125+
def self.tojis: (String str) -> String
126+
127+
# <!--
128+
# rdoc-file=ext/nkf/lib/kconv.rb
129+
# - Kconv.tolocale => string
130+
# -->
131+
# Convert `self` to locale encoding
132+
#
133+
def self.tolocale: (String str) -> String
134+
135+
# <!--
136+
# rdoc-file=ext/nkf/lib/kconv.rb
137+
# - Kconv.tosjis(str) => string
138+
# -->
139+
# Convert `str` to Shift_JIS
140+
#
141+
def self.tosjis: (String str) -> String
142+
143+
# <!--
144+
# rdoc-file=ext/nkf/lib/kconv.rb
145+
# - Kconv.toutf16(str) => string
146+
# -->
147+
# Convert `str` to UTF-16
148+
#
149+
def self.toutf16: (String str) -> String
150+
151+
# <!--
152+
# rdoc-file=ext/nkf/lib/kconv.rb
153+
# - Kconv.toutf32(str) => string
154+
# -->
155+
# Convert `str` to UTF-32
156+
#
157+
def self.toutf32: (String str) -> String
158+
159+
# <!--
160+
# rdoc-file=ext/nkf/lib/kconv.rb
161+
# - Kconv.toutf8(str) => string
162+
# -->
163+
# Convert `str` to UTF-8
164+
#
165+
def self.toutf8: (String str) -> String
166+
end

0 commit comments

Comments
 (0)