rbs 3.2.2 → 3.3.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +1 -1
- data/.github/workflows/ruby.yml +7 -2
- data/CHANGELOG.md +85 -0
- data/Gemfile.lock +14 -14
- data/README.md +11 -2
- data/Rakefile +10 -7
- data/Steepfile +7 -7
- data/core/basic_object.rbs +7 -7
- data/core/binding.rbs +3 -3
- data/core/builtin.rbs +171 -5
- data/core/constants.rbs +17 -17
- data/core/dir.rbs +3 -3
- data/core/encoding.rbs +434 -628
- data/core/enumerator.rbs +37 -0
- data/core/exception.rbs +11 -11
- data/core/false_class.rbs +5 -11
- data/core/fiber.rbs +3 -3
- data/core/file_test.rbs +28 -26
- data/core/kernel.rbs +900 -21
- data/core/marshal.rbs +24 -14
- data/core/match_data.rbs +8 -8
- data/core/math.rbs +57 -53
- data/core/method.rbs +3 -1
- data/core/module.rbs +38 -36
- data/core/nil_class.rbs +7 -13
- data/core/object.rbs +3 -966
- data/core/process.rbs +3 -3
- data/core/ractor.rbs +2 -2
- data/core/rb_config.rbs +64 -43
- data/core/regexp.rbs +3 -3
- data/core/signal.rbs +10 -4
- data/core/struct.rbs +1 -1
- data/core/thread.rbs +7 -7
- data/core/thread_group.rbs +9 -9
- data/core/true_class.rbs +5 -11
- data/core/unbound_method.rbs +56 -7
- data/core/warning.rbs +33 -0
- data/docs/collection.md +56 -6
- data/docs/data_and_struct.md +57 -0
- data/docs/stdlib.md +61 -2
- data/docs/syntax.md +123 -2
- data/ext/rbs_extension/lexer.c +624 -569
- data/ext/rbs_extension/lexer.h +1 -0
- data/ext/rbs_extension/lexer.re +1 -0
- data/ext/rbs_extension/lexstate.c +1 -0
- data/ext/rbs_extension/parser.c +6 -0
- data/goodcheck.yml +2 -2
- data/lib/rbs/annotate/formatter.rb +13 -3
- data/lib/rbs/annotate/rdoc_source.rb +10 -1
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +80 -0
- data/lib/rbs/cli.rb +151 -16
- data/lib/rbs/collection/config/lockfile.rb +0 -25
- data/lib/rbs/collection/config/lockfile_generator.rb +0 -6
- data/lib/rbs/collection/installer.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +6 -4
- data/lib/rbs/collection/sources/local.rb +7 -5
- data/lib/rbs/diff.rb +104 -0
- data/lib/rbs/environment.rb +1 -1
- data/lib/rbs/method_type.rb +23 -0
- data/lib/rbs/prototype/rb.rb +2 -9
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +236 -0
- data/lib/rbs/prototype/runtime.rb +234 -150
- data/lib/rbs/sorter.rb +144 -117
- data/lib/rbs/test/guaranteed.rb +31 -0
- data/lib/rbs/test/type_check.rb +4 -4
- data/lib/rbs/test.rb +3 -0
- data/lib/rbs/types.rb +184 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +4 -4
- data/lib/rbs.rb +1 -0
- data/rbs.gemspec +1 -0
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile.rbs +0 -6
- data/sig/diff.rbs +23 -0
- data/sig/errors.rbs +1 -5
- data/sig/method_types.rbs +6 -0
- data/sig/prototype/runtime.rbs +108 -0
- data/sig/rdoc/rbs.rbs +4 -0
- data/sig/shims/bundler.rbs +5 -0
- data/sig/sorter.rbs +23 -5
- data/sig/types.rbs +29 -0
- data/stdlib/benchmark/0/benchmark.rbs +1 -1
- data/stdlib/cgi/0/core.rbs +2 -2
- data/stdlib/did_you_mean/0/did_you_mean.rbs +2 -2
- data/stdlib/digest/0/digest.rbs +1 -1
- data/stdlib/fileutils/0/fileutils.rbs +1 -1
- data/stdlib/forwardable/0/forwardable.rbs +4 -4
- data/stdlib/io-console/0/io-console.rbs +1 -1
- data/stdlib/json/0/json.rbs +37 -0
- data/stdlib/logger/0/logger.rbs +2 -2
- data/stdlib/net-http/0/manifest.yaml +1 -1
- data/stdlib/net-http/0/net-http.rbs +16 -63
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/openssl/0/openssl.rbs +1 -1
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +301 -0
- data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +391 -0
- data/stdlib/{yaml → psych}/0/store.rbs +2 -2
- data/stdlib/rdoc/0/code_object.rbs +55 -0
- data/stdlib/rdoc/0/comment.rbs +60 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +119 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +0 -372
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/socket/0/basic_socket.rbs +1 -1
- data/stdlib/socket/0/socket.rbs +1 -1
- data/stdlib/uri/0/common.rbs +1 -1
- data/stdlib/yaml/0/manifest.yaml +1 -2
- data/stdlib/yaml/0/yaml.rbs +1 -199
- metadata +46 -9
- data/sig/shims/pp.rbs +0 -3
- data/sig/shims.rbs +0 -47
data/core/encoding.rbs
CHANGED
@@ -27,7 +27,33 @@
|
|
27
27
|
# characters in the ASCII range are considered as ASCII characters. This is
|
28
28
|
# useful when you use other ASCII-compatible encodings.
|
29
29
|
#
|
30
|
-
class Encoding
|
30
|
+
class Encoding
|
31
|
+
def self._load: [T] (T) -> T
|
32
|
+
|
33
|
+
# <!--
|
34
|
+
# rdoc-file=encoding.c
|
35
|
+
# - Encoding.locale_charmap -> string
|
36
|
+
# -->
|
37
|
+
# Returns the locale charmap name. It returns nil if no appropriate information.
|
38
|
+
#
|
39
|
+
# Debian GNU/Linux
|
40
|
+
# LANG=C
|
41
|
+
# Encoding.locale_charmap #=> "ANSI_X3.4-1968"
|
42
|
+
# LANG=ja_JP.EUC-JP
|
43
|
+
# Encoding.locale_charmap #=> "EUC-JP"
|
44
|
+
#
|
45
|
+
# SunOS 5
|
46
|
+
# LANG=C
|
47
|
+
# Encoding.locale_charmap #=> "646"
|
48
|
+
# LANG=ja
|
49
|
+
# Encoding.locale_charmap #=> "eucJP"
|
50
|
+
#
|
51
|
+
# The result is highly platform dependent. So
|
52
|
+
# Encoding.find(Encoding.locale_charmap) may cause an error. If you need some
|
53
|
+
# encoding object even for unknown locale, Encoding.find("locale") can be used.
|
54
|
+
#
|
55
|
+
def self.locale_charmap: () -> String
|
56
|
+
|
31
57
|
# <!--
|
32
58
|
# rdoc-file=encoding.c
|
33
59
|
# - Encoding.aliases -> {"alias1" => "orig1", "alias2" => "orig2", ...}
|
@@ -38,7 +64,7 @@ class Encoding < Object
|
|
38
64
|
# #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1968"=>"US-ASCII",
|
39
65
|
# "SJIS"=>"Windows-31J", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
|
40
66
|
#
|
41
|
-
def self.aliases: () ->
|
67
|
+
def self.aliases: () -> Hash[String, String]
|
42
68
|
|
43
69
|
# <!--
|
44
70
|
# rdoc-file=encoding.c
|
@@ -108,8 +134,8 @@ class Encoding < Object
|
|
108
134
|
# See Encoding::default_external for information on how the default external
|
109
135
|
# encoding is used.
|
110
136
|
#
|
111
|
-
def self.default_external=: (
|
112
|
-
| (
|
137
|
+
def self.default_external=: (Encoding enc) -> Encoding
|
138
|
+
| [T < _ToStr] (T enc) -> T
|
113
139
|
|
114
140
|
# <!--
|
115
141
|
# rdoc-file=encoding.c
|
@@ -155,9 +181,9 @@ class Encoding < Object
|
|
155
181
|
# See Encoding::default_internal for information on how the default internal
|
156
182
|
# encoding is used.
|
157
183
|
#
|
158
|
-
def self.default_internal=: (
|
159
|
-
| (
|
160
|
-
| (nil
|
184
|
+
def self.default_internal=: (Encoding enc) -> Encoding
|
185
|
+
| [T < _ToStr] (T enc) -> T
|
186
|
+
| (nil) -> nil
|
161
187
|
|
162
188
|
# <!--
|
163
189
|
# rdoc-file=encoding.c
|
@@ -184,7 +210,7 @@ class Encoding < Object
|
|
184
210
|
# `Encoding.find("internal")` however returns nil when no encoding named
|
185
211
|
# "internal", in other words, when Ruby has no default internal encoding.
|
186
212
|
#
|
187
|
-
def self.find: (
|
213
|
+
def self.find: (encoding enc) -> Encoding?
|
188
214
|
|
189
215
|
# <!--
|
190
216
|
# rdoc-file=encoding.c
|
@@ -203,7 +229,7 @@ class Encoding < Object
|
|
203
229
|
# #=> [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>,
|
204
230
|
# #<Encoding:US-ASCII>, #<Encoding:ISO-2022-JP (dummy)>]
|
205
231
|
#
|
206
|
-
def self.list: () ->
|
232
|
+
def self.list: () -> Array[Encoding]
|
207
233
|
|
208
234
|
# <!--
|
209
235
|
# rdoc-file=encoding.c
|
@@ -217,7 +243,7 @@ class Encoding < Object
|
|
217
243
|
# "Windows-31J",
|
218
244
|
# "BINARY", "CP932", "eucJP"]
|
219
245
|
#
|
220
|
-
def self.name_list: () ->
|
246
|
+
def self.name_list: () -> Array[String]
|
221
247
|
|
222
248
|
# <!--
|
223
249
|
# rdoc-file=encoding.c
|
@@ -269,17 +295,7 @@ class Encoding < Object
|
|
269
295
|
#
|
270
296
|
# Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"]
|
271
297
|
#
|
272
|
-
def names: () ->
|
273
|
-
|
274
|
-
# <!--
|
275
|
-
# rdoc-file=encoding.c
|
276
|
-
# - enc.replicate(name) -> encoding
|
277
|
-
# -->
|
278
|
-
# Returns a replicated encoding of *enc* whose name is *name*. The new encoding
|
279
|
-
# should have the same byte structure of *enc*. If *name* is used by another
|
280
|
-
# encoding, raise ArgumentError.
|
281
|
-
#
|
282
|
-
def replicate: (String name) -> Encoding
|
298
|
+
def names: () -> Array[String]
|
283
299
|
|
284
300
|
# <!--
|
285
301
|
# rdoc-file=encoding.c
|
@@ -290,427 +306,405 @@ class Encoding < Object
|
|
290
306
|
#
|
291
307
|
# Encoding::UTF_8.name #=> "UTF-8"
|
292
308
|
#
|
293
|
-
|
309
|
+
alias to_s name
|
310
|
+
|
311
|
+
ANSI_X3_4_1968: Encoding
|
312
|
+
ASCII: Encoding
|
313
|
+
ASCII_8BIT: Encoding
|
314
|
+
BIG5: Encoding
|
315
|
+
BIG5_HKSCS: Encoding
|
316
|
+
BIG5_HKSCS_2008: Encoding
|
317
|
+
BIG5_UAO: Encoding
|
318
|
+
BINARY: Encoding
|
319
|
+
Big5: Encoding
|
320
|
+
Big5_HKSCS: Encoding
|
321
|
+
Big5_HKSCS_2008: Encoding
|
322
|
+
Big5_UAO: Encoding
|
323
|
+
CESU_8: Encoding
|
324
|
+
CP1250: Encoding
|
325
|
+
CP1251: Encoding
|
326
|
+
CP1252: Encoding
|
327
|
+
CP1253: Encoding
|
328
|
+
CP1254: Encoding
|
329
|
+
CP1255: Encoding
|
330
|
+
CP1256: Encoding
|
331
|
+
CP1257: Encoding
|
332
|
+
CP1258: Encoding
|
333
|
+
CP437: Encoding
|
334
|
+
CP50220: Encoding
|
335
|
+
CP50221: Encoding
|
336
|
+
CP51932: Encoding
|
337
|
+
CP65000: Encoding
|
338
|
+
CP65001: Encoding
|
339
|
+
CP737: Encoding
|
340
|
+
CP775: Encoding
|
341
|
+
CP850: Encoding
|
342
|
+
CP852: Encoding
|
343
|
+
CP855: Encoding
|
344
|
+
CP857: Encoding
|
345
|
+
CP860: Encoding
|
346
|
+
CP861: Encoding
|
347
|
+
CP862: Encoding
|
348
|
+
CP863: Encoding
|
349
|
+
CP864: Encoding
|
350
|
+
CP865: Encoding
|
351
|
+
CP866: Encoding
|
352
|
+
CP869: Encoding
|
353
|
+
CP874: Encoding
|
354
|
+
CP878: Encoding
|
355
|
+
CP932: Encoding
|
356
|
+
CP936: Encoding
|
357
|
+
CP949: Encoding
|
358
|
+
CP950: Encoding
|
359
|
+
CP951: Encoding
|
360
|
+
CSWINDOWS31J: Encoding
|
361
|
+
CsWindows31J: Encoding
|
362
|
+
EBCDIC_CP_US: Encoding
|
363
|
+
EMACS_MULE: Encoding
|
364
|
+
EUCCN: Encoding
|
365
|
+
EUCJP: Encoding
|
366
|
+
EUCJP_MS: Encoding
|
367
|
+
EUCKR: Encoding
|
368
|
+
EUCTW: Encoding
|
369
|
+
EUC_CN: Encoding
|
370
|
+
EUC_JISX0213: Encoding
|
371
|
+
EUC_JIS_2004: Encoding
|
372
|
+
EUC_JP: Encoding
|
373
|
+
EUC_JP_MS: Encoding
|
374
|
+
EUC_KR: Encoding
|
375
|
+
EUC_TW: Encoding
|
376
|
+
Emacs_Mule: Encoding
|
377
|
+
EucCN: Encoding
|
378
|
+
EucJP: Encoding
|
379
|
+
EucJP_ms: Encoding
|
380
|
+
EucKR: Encoding
|
381
|
+
EucTW: Encoding
|
382
|
+
GB12345: Encoding
|
383
|
+
GB18030: Encoding
|
384
|
+
GB1988: Encoding
|
385
|
+
GB2312: Encoding
|
386
|
+
GBK: Encoding
|
387
|
+
IBM037: Encoding
|
388
|
+
IBM437: Encoding
|
389
|
+
IBM737: Encoding
|
390
|
+
IBM720: Encoding
|
391
|
+
CP720: Encoding
|
392
|
+
IBM775: Encoding
|
393
|
+
IBM850: Encoding
|
394
|
+
IBM852: Encoding
|
395
|
+
IBM855: Encoding
|
396
|
+
IBM857: Encoding
|
397
|
+
IBM860: Encoding
|
398
|
+
IBM861: Encoding
|
399
|
+
IBM862: Encoding
|
400
|
+
IBM863: Encoding
|
401
|
+
IBM864: Encoding
|
402
|
+
IBM865: Encoding
|
403
|
+
IBM866: Encoding
|
404
|
+
IBM869: Encoding
|
405
|
+
ISO2022_JP: Encoding
|
406
|
+
ISO2022_JP2: Encoding
|
407
|
+
ISO8859_1: Encoding
|
408
|
+
ISO8859_10: Encoding
|
409
|
+
ISO8859_11: Encoding
|
410
|
+
ISO8859_13: Encoding
|
411
|
+
ISO8859_14: Encoding
|
412
|
+
ISO8859_15: Encoding
|
413
|
+
ISO8859_16: Encoding
|
414
|
+
ISO8859_2: Encoding
|
415
|
+
ISO8859_3: Encoding
|
416
|
+
ISO8859_4: Encoding
|
417
|
+
ISO8859_5: Encoding
|
418
|
+
ISO8859_6: Encoding
|
419
|
+
ISO8859_7: Encoding
|
420
|
+
ISO8859_8: Encoding
|
421
|
+
ISO8859_9: Encoding
|
422
|
+
ISO_2022_JP: Encoding
|
423
|
+
ISO_2022_JP_2: Encoding
|
424
|
+
ISO_2022_JP_KDDI: Encoding
|
425
|
+
ISO_8859_1: Encoding
|
426
|
+
ISO_8859_10: Encoding
|
427
|
+
ISO_8859_11: Encoding
|
428
|
+
ISO_8859_13: Encoding
|
429
|
+
ISO_8859_14: Encoding
|
430
|
+
ISO_8859_15: Encoding
|
431
|
+
ISO_8859_16: Encoding
|
432
|
+
ISO_8859_2: Encoding
|
433
|
+
ISO_8859_3: Encoding
|
434
|
+
ISO_8859_4: Encoding
|
435
|
+
ISO_8859_5: Encoding
|
436
|
+
ISO_8859_6: Encoding
|
437
|
+
ISO_8859_7: Encoding
|
438
|
+
ISO_8859_8: Encoding
|
439
|
+
ISO_8859_9: Encoding
|
440
|
+
KOI8_R: Encoding
|
441
|
+
KOI8_U: Encoding
|
442
|
+
MACCENTEURO: Encoding
|
443
|
+
MACCROATIAN: Encoding
|
444
|
+
MACCYRILLIC: Encoding
|
445
|
+
MACGREEK: Encoding
|
446
|
+
MACICELAND: Encoding
|
447
|
+
MACJAPAN: Encoding
|
448
|
+
MACJAPANESE: Encoding
|
449
|
+
MACROMAN: Encoding
|
450
|
+
MACROMANIA: Encoding
|
451
|
+
MACTHAI: Encoding
|
452
|
+
MACTURKISH: Encoding
|
453
|
+
MACUKRAINE: Encoding
|
454
|
+
MacCentEuro: Encoding
|
455
|
+
MacCroatian: Encoding
|
456
|
+
MacCyrillic: Encoding
|
457
|
+
MacGreek: Encoding
|
458
|
+
MacIceland: Encoding
|
459
|
+
MacJapan: Encoding
|
460
|
+
MacJapanese: Encoding
|
461
|
+
MacRoman: Encoding
|
462
|
+
MacRomania: Encoding
|
463
|
+
MacThai: Encoding
|
464
|
+
MacTurkish: Encoding
|
465
|
+
MacUkraine: Encoding
|
466
|
+
PCK: Encoding
|
467
|
+
SHIFT_JIS: Encoding
|
468
|
+
SJIS: Encoding
|
469
|
+
SJIS_DOCOMO: Encoding
|
470
|
+
SJIS_DoCoMo: Encoding
|
471
|
+
SJIS_KDDI: Encoding
|
472
|
+
SJIS_SOFTBANK: Encoding
|
473
|
+
SJIS_SoftBank: Encoding
|
474
|
+
STATELESS_ISO_2022_JP: Encoding
|
475
|
+
STATELESS_ISO_2022_JP_KDDI: Encoding
|
476
|
+
Shift_JIS: Encoding
|
477
|
+
Stateless_ISO_2022_JP: Encoding
|
478
|
+
Stateless_ISO_2022_JP_KDDI: Encoding
|
479
|
+
TIS_620: Encoding
|
480
|
+
UCS_2BE: Encoding
|
481
|
+
UCS_4BE: Encoding
|
482
|
+
UCS_4LE: Encoding
|
483
|
+
US_ASCII: Encoding
|
484
|
+
UTF8_DOCOMO: Encoding
|
485
|
+
UTF8_DoCoMo: Encoding
|
486
|
+
UTF8_KDDI: Encoding
|
487
|
+
UTF8_MAC: Encoding
|
488
|
+
UTF8_SOFTBANK: Encoding
|
489
|
+
UTF8_SoftBank: Encoding
|
490
|
+
UTF_16: Encoding
|
491
|
+
UTF_16BE: Encoding
|
492
|
+
UTF_16LE: Encoding
|
493
|
+
UTF_32: Encoding
|
494
|
+
UTF_32BE: Encoding
|
495
|
+
UTF_32LE: Encoding
|
496
|
+
UTF_7: Encoding
|
497
|
+
UTF_8: Encoding
|
498
|
+
UTF_8_HFS: Encoding
|
499
|
+
UTF_8_MAC: Encoding
|
500
|
+
WINDOWS_1250: Encoding
|
501
|
+
WINDOWS_1251: Encoding
|
502
|
+
WINDOWS_1252: Encoding
|
503
|
+
WINDOWS_1253: Encoding
|
504
|
+
WINDOWS_1254: Encoding
|
505
|
+
WINDOWS_1255: Encoding
|
506
|
+
WINDOWS_1256: Encoding
|
507
|
+
WINDOWS_1257: Encoding
|
508
|
+
WINDOWS_1258: Encoding
|
509
|
+
WINDOWS_31J: Encoding
|
510
|
+
WINDOWS_874: Encoding
|
511
|
+
Windows_1250: Encoding
|
512
|
+
Windows_1251: Encoding
|
513
|
+
Windows_1252: Encoding
|
514
|
+
Windows_1253: Encoding
|
515
|
+
Windows_1254: Encoding
|
516
|
+
Windows_1255: Encoding
|
517
|
+
Windows_1256: Encoding
|
518
|
+
Windows_1257: Encoding
|
519
|
+
Windows_1258: Encoding
|
520
|
+
Windows_31J: Encoding
|
521
|
+
Windows_874: Encoding
|
522
|
+
|
523
|
+
# <!-- rdoc-file=error.c -->
|
524
|
+
# Raised by Encoding and String methods when the source encoding is incompatible
|
525
|
+
# with the target encoding.
|
526
|
+
#
|
527
|
+
class CompatibilityError < EncodingError
|
528
|
+
end
|
529
|
+
|
530
|
+
# <!-- rdoc-file=transcode.c -->
|
531
|
+
# Raised by transcoding methods when a named encoding does not correspond with a
|
532
|
+
# known converter.
|
533
|
+
#
|
534
|
+
class ConverterNotFoundError < EncodingError
|
535
|
+
end
|
536
|
+
|
537
|
+
# <!-- rdoc-file=transcode.c -->
|
538
|
+
# Raised by Encoding and String methods when the string being transcoded
|
539
|
+
# contains a byte invalid for the either the source or target encoding.
|
540
|
+
#
|
541
|
+
class InvalidByteSequenceError < EncodingError
|
542
|
+
# <!--
|
543
|
+
# rdoc-file=transcode.c
|
544
|
+
# - ecerr.destination_encoding -> string
|
545
|
+
# -->
|
546
|
+
# Returns the destination encoding as an encoding object.
|
547
|
+
#
|
548
|
+
def destination_encoding: () -> Encoding
|
549
|
+
|
550
|
+
# <!--
|
551
|
+
# rdoc-file=transcode.c
|
552
|
+
# - ecerr.destination_encoding_name -> string
|
553
|
+
# -->
|
554
|
+
# Returns the destination encoding name as a string.
|
555
|
+
#
|
556
|
+
def destination_encoding_name: () -> String
|
557
|
+
|
558
|
+
# <!--
|
559
|
+
# rdoc-file=transcode.c
|
560
|
+
# - ecerr.error_bytes -> string
|
561
|
+
# -->
|
562
|
+
# Returns the discarded bytes when Encoding::InvalidByteSequenceError occurs.
|
563
|
+
#
|
564
|
+
# ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
565
|
+
# begin
|
566
|
+
# ec.convert("abc\xA1\xFFdef")
|
567
|
+
# rescue Encoding::InvalidByteSequenceError
|
568
|
+
# p $! #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
|
569
|
+
# puts $!.error_bytes.dump #=> "\xA1"
|
570
|
+
# puts $!.readagain_bytes.dump #=> "\xFF"
|
571
|
+
# end
|
572
|
+
#
|
573
|
+
def error_bytes: () -> String
|
574
|
+
|
575
|
+
# <!--
|
576
|
+
# rdoc-file=transcode.c
|
577
|
+
# - ecerr.incomplete_input? -> true or false
|
578
|
+
# -->
|
579
|
+
# Returns true if the invalid byte sequence error is caused by premature end of
|
580
|
+
# string.
|
581
|
+
#
|
582
|
+
# ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
583
|
+
#
|
584
|
+
# begin
|
585
|
+
# ec.convert("abc\xA1z")
|
586
|
+
# rescue Encoding::InvalidByteSequenceError
|
587
|
+
# p $! #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "z" on EUC-JP>
|
588
|
+
# p $!.incomplete_input? #=> false
|
589
|
+
# end
|
590
|
+
#
|
591
|
+
# begin
|
592
|
+
# ec.convert("abc\xA1")
|
593
|
+
# ec.finish
|
594
|
+
# rescue Encoding::InvalidByteSequenceError
|
595
|
+
# p $! #=> #<Encoding::InvalidByteSequenceError: incomplete "\xA1" on EUC-JP>
|
596
|
+
# p $!.incomplete_input? #=> true
|
597
|
+
# end
|
598
|
+
#
|
599
|
+
def incomplete_input?: () -> bool
|
600
|
+
|
601
|
+
# <!--
|
602
|
+
# rdoc-file=transcode.c
|
603
|
+
# - ecerr.readagain_bytes -> string
|
604
|
+
# -->
|
605
|
+
# Returns the bytes to be read again when Encoding::InvalidByteSequenceError
|
606
|
+
# occurs.
|
607
|
+
#
|
608
|
+
def readagain_bytes: () -> String
|
609
|
+
|
610
|
+
# <!--
|
611
|
+
# rdoc-file=transcode.c
|
612
|
+
# - ecerr.source_encoding -> encoding
|
613
|
+
# -->
|
614
|
+
# Returns the source encoding as an encoding object.
|
615
|
+
#
|
616
|
+
# Note that the result may not be equal to the source encoding of the encoding
|
617
|
+
# converter if the conversion has multiple steps.
|
618
|
+
#
|
619
|
+
# ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP
|
620
|
+
# begin
|
621
|
+
# ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP.
|
622
|
+
# rescue Encoding::UndefinedConversionError
|
623
|
+
# p $!.source_encoding #=> #<Encoding:UTF-8>
|
624
|
+
# p $!.destination_encoding #=> #<Encoding:EUC-JP>
|
625
|
+
# p $!.source_encoding_name #=> "UTF-8"
|
626
|
+
# p $!.destination_encoding_name #=> "EUC-JP"
|
627
|
+
# end
|
628
|
+
#
|
629
|
+
def source_encoding: () -> Encoding
|
630
|
+
|
631
|
+
# <!--
|
632
|
+
# rdoc-file=transcode.c
|
633
|
+
# - ecerr.source_encoding_name -> string
|
634
|
+
# -->
|
635
|
+
# Returns the source encoding name as a string.
|
636
|
+
#
|
637
|
+
def source_encoding_name: () -> String
|
638
|
+
end
|
639
|
+
|
640
|
+
# <!-- rdoc-file=transcode.c -->
|
641
|
+
# Raised by Encoding and String methods when a transcoding operation fails.
|
642
|
+
#
|
643
|
+
class UndefinedConversionError < EncodingError
|
644
|
+
# <!--
|
645
|
+
# rdoc-file=transcode.c
|
646
|
+
# - ecerr.destination_encoding -> string
|
647
|
+
# -->
|
648
|
+
# Returns the destination encoding as an encoding object.
|
649
|
+
#
|
650
|
+
def destination_encoding: () -> Encoding
|
651
|
+
|
652
|
+
# <!--
|
653
|
+
# rdoc-file=transcode.c
|
654
|
+
# - ecerr.destination_encoding_name -> string
|
655
|
+
# -->
|
656
|
+
# Returns the destination encoding name as a string.
|
657
|
+
#
|
658
|
+
def destination_encoding_name: () -> String
|
659
|
+
|
660
|
+
# <!--
|
661
|
+
# rdoc-file=transcode.c
|
662
|
+
# - ecerr.error_char -> string
|
663
|
+
# -->
|
664
|
+
# Returns the one-character string which cause
|
665
|
+
# Encoding::UndefinedConversionError.
|
666
|
+
#
|
667
|
+
# ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
|
668
|
+
# begin
|
669
|
+
# ec.convert("\xa0")
|
670
|
+
# rescue Encoding::UndefinedConversionError
|
671
|
+
# puts $!.error_char.dump #=> "\xC2\xA0"
|
672
|
+
# p $!.error_char.encoding #=> #<Encoding:UTF-8>
|
673
|
+
# end
|
674
|
+
#
|
675
|
+
def error_char: () -> String
|
676
|
+
|
677
|
+
# <!--
|
678
|
+
# rdoc-file=transcode.c
|
679
|
+
# - ecerr.source_encoding -> encoding
|
680
|
+
# -->
|
681
|
+
# Returns the source encoding as an encoding object.
|
682
|
+
#
|
683
|
+
# Note that the result may not be equal to the source encoding of the encoding
|
684
|
+
# converter if the conversion has multiple steps.
|
685
|
+
#
|
686
|
+
# ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP
|
687
|
+
# begin
|
688
|
+
# ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP.
|
689
|
+
# rescue Encoding::UndefinedConversionError
|
690
|
+
# p $!.source_encoding #=> #<Encoding:UTF-8>
|
691
|
+
# p $!.destination_encoding #=> #<Encoding:EUC-JP>
|
692
|
+
# p $!.source_encoding_name #=> "UTF-8"
|
693
|
+
# p $!.destination_encoding_name #=> "EUC-JP"
|
694
|
+
# end
|
695
|
+
#
|
696
|
+
def source_encoding: () -> Encoding
|
697
|
+
|
698
|
+
# <!--
|
699
|
+
# rdoc-file=transcode.c
|
700
|
+
# - ecerr.source_encoding_name -> string
|
701
|
+
# -->
|
702
|
+
# Returns the source encoding name as a string.
|
703
|
+
#
|
704
|
+
def source_encoding_name: () -> String
|
705
|
+
end
|
294
706
|
end
|
295
707
|
|
296
|
-
Encoding::ANSI_X3_4_1968: Encoding
|
297
|
-
|
298
|
-
Encoding::ASCII: Encoding
|
299
|
-
|
300
|
-
Encoding::ASCII_8BIT: Encoding
|
301
|
-
|
302
|
-
Encoding::BIG5: Encoding
|
303
|
-
|
304
|
-
Encoding::BIG5_HKSCS: Encoding
|
305
|
-
|
306
|
-
Encoding::BIG5_HKSCS_2008: Encoding
|
307
|
-
|
308
|
-
Encoding::BIG5_UAO: Encoding
|
309
|
-
|
310
|
-
Encoding::BINARY: Encoding
|
311
|
-
|
312
|
-
Encoding::Big5: Encoding
|
313
|
-
|
314
|
-
Encoding::Big5_HKSCS: Encoding
|
315
|
-
|
316
|
-
Encoding::Big5_HKSCS_2008: Encoding
|
317
|
-
|
318
|
-
Encoding::Big5_UAO: Encoding
|
319
|
-
|
320
|
-
Encoding::CESU_8: Encoding
|
321
|
-
|
322
|
-
Encoding::CP1250: Encoding
|
323
|
-
|
324
|
-
Encoding::CP1251: Encoding
|
325
|
-
|
326
|
-
Encoding::CP1252: Encoding
|
327
|
-
|
328
|
-
Encoding::CP1253: Encoding
|
329
|
-
|
330
|
-
Encoding::CP1254: Encoding
|
331
|
-
|
332
|
-
Encoding::CP1255: Encoding
|
333
|
-
|
334
|
-
Encoding::CP1256: Encoding
|
335
|
-
|
336
|
-
Encoding::CP1257: Encoding
|
337
|
-
|
338
|
-
Encoding::CP1258: Encoding
|
339
|
-
|
340
|
-
Encoding::CP437: Encoding
|
341
|
-
|
342
|
-
Encoding::CP50220: Encoding
|
343
|
-
|
344
|
-
Encoding::CP50221: Encoding
|
345
|
-
|
346
|
-
Encoding::CP51932: Encoding
|
347
|
-
|
348
|
-
Encoding::CP65000: Encoding
|
349
|
-
|
350
|
-
Encoding::CP65001: Encoding
|
351
|
-
|
352
|
-
Encoding::CP737: Encoding
|
353
|
-
|
354
|
-
Encoding::CP775: Encoding
|
355
|
-
|
356
|
-
Encoding::CP850: Encoding
|
357
|
-
|
358
|
-
Encoding::CP852: Encoding
|
359
|
-
|
360
|
-
Encoding::CP855: Encoding
|
361
|
-
|
362
|
-
Encoding::CP857: Encoding
|
363
|
-
|
364
|
-
Encoding::CP860: Encoding
|
365
|
-
|
366
|
-
Encoding::CP861: Encoding
|
367
|
-
|
368
|
-
Encoding::CP862: Encoding
|
369
|
-
|
370
|
-
Encoding::CP863: Encoding
|
371
|
-
|
372
|
-
Encoding::CP864: Encoding
|
373
|
-
|
374
|
-
Encoding::CP865: Encoding
|
375
|
-
|
376
|
-
Encoding::CP866: Encoding
|
377
|
-
|
378
|
-
Encoding::CP869: Encoding
|
379
|
-
|
380
|
-
Encoding::CP874: Encoding
|
381
|
-
|
382
|
-
Encoding::CP878: Encoding
|
383
|
-
|
384
|
-
Encoding::CP932: Encoding
|
385
|
-
|
386
|
-
Encoding::CP936: Encoding
|
387
|
-
|
388
|
-
Encoding::CP949: Encoding
|
389
|
-
|
390
|
-
Encoding::CP950: Encoding
|
391
|
-
|
392
|
-
Encoding::CP951: Encoding
|
393
|
-
|
394
|
-
Encoding::CSWINDOWS31J: Encoding
|
395
|
-
|
396
|
-
Encoding::CsWindows31J: Encoding
|
397
|
-
|
398
|
-
Encoding::EBCDIC_CP_US: Encoding
|
399
|
-
|
400
|
-
Encoding::EMACS_MULE: Encoding
|
401
|
-
|
402
|
-
Encoding::EUCCN: Encoding
|
403
|
-
|
404
|
-
Encoding::EUCJP: Encoding
|
405
|
-
|
406
|
-
Encoding::EUCJP_MS: Encoding
|
407
|
-
|
408
|
-
Encoding::EUCKR: Encoding
|
409
|
-
|
410
|
-
Encoding::EUCTW: Encoding
|
411
|
-
|
412
|
-
Encoding::EUC_CN: Encoding
|
413
|
-
|
414
|
-
Encoding::EUC_JISX0213: Encoding
|
415
|
-
|
416
|
-
Encoding::EUC_JIS_2004: Encoding
|
417
|
-
|
418
|
-
Encoding::EUC_JP: Encoding
|
419
|
-
|
420
|
-
Encoding::EUC_JP_MS: Encoding
|
421
|
-
|
422
|
-
Encoding::EUC_KR: Encoding
|
423
|
-
|
424
|
-
Encoding::EUC_TW: Encoding
|
425
|
-
|
426
|
-
Encoding::Emacs_Mule: Encoding
|
427
|
-
|
428
|
-
Encoding::EucCN: Encoding
|
429
|
-
|
430
|
-
Encoding::EucJP: Encoding
|
431
|
-
|
432
|
-
Encoding::EucJP_ms: Encoding
|
433
|
-
|
434
|
-
Encoding::EucKR: Encoding
|
435
|
-
|
436
|
-
Encoding::EucTW: Encoding
|
437
|
-
|
438
|
-
Encoding::GB12345: Encoding
|
439
|
-
|
440
|
-
Encoding::GB18030: Encoding
|
441
|
-
|
442
|
-
Encoding::GB1988: Encoding
|
443
|
-
|
444
|
-
Encoding::GB2312: Encoding
|
445
|
-
|
446
|
-
Encoding::GBK: Encoding
|
447
|
-
|
448
|
-
Encoding::IBM037: Encoding
|
449
|
-
|
450
|
-
Encoding::IBM437: Encoding
|
451
|
-
|
452
|
-
Encoding::IBM737: Encoding
|
453
|
-
|
454
|
-
Encoding::IBM775: Encoding
|
455
|
-
|
456
|
-
Encoding::IBM850: Encoding
|
457
|
-
|
458
|
-
Encoding::IBM852: Encoding
|
459
|
-
|
460
|
-
Encoding::IBM855: Encoding
|
461
|
-
|
462
|
-
Encoding::IBM857: Encoding
|
463
|
-
|
464
|
-
Encoding::IBM860: Encoding
|
465
|
-
|
466
|
-
Encoding::IBM861: Encoding
|
467
|
-
|
468
|
-
Encoding::IBM862: Encoding
|
469
|
-
|
470
|
-
Encoding::IBM863: Encoding
|
471
|
-
|
472
|
-
Encoding::IBM864: Encoding
|
473
|
-
|
474
|
-
Encoding::IBM865: Encoding
|
475
|
-
|
476
|
-
Encoding::IBM866: Encoding
|
477
|
-
|
478
|
-
Encoding::IBM869: Encoding
|
479
|
-
|
480
|
-
Encoding::ISO2022_JP: Encoding
|
481
|
-
|
482
|
-
Encoding::ISO2022_JP2: Encoding
|
483
|
-
|
484
|
-
Encoding::ISO8859_1: Encoding
|
485
|
-
|
486
|
-
Encoding::ISO8859_10: Encoding
|
487
|
-
|
488
|
-
Encoding::ISO8859_11: Encoding
|
489
|
-
|
490
|
-
Encoding::ISO8859_13: Encoding
|
491
|
-
|
492
|
-
Encoding::ISO8859_14: Encoding
|
493
|
-
|
494
|
-
Encoding::ISO8859_15: Encoding
|
495
|
-
|
496
|
-
Encoding::ISO8859_16: Encoding
|
497
|
-
|
498
|
-
Encoding::ISO8859_2: Encoding
|
499
|
-
|
500
|
-
Encoding::ISO8859_3: Encoding
|
501
|
-
|
502
|
-
Encoding::ISO8859_4: Encoding
|
503
|
-
|
504
|
-
Encoding::ISO8859_5: Encoding
|
505
|
-
|
506
|
-
Encoding::ISO8859_6: Encoding
|
507
|
-
|
508
|
-
Encoding::ISO8859_7: Encoding
|
509
|
-
|
510
|
-
Encoding::ISO8859_8: Encoding
|
511
|
-
|
512
|
-
Encoding::ISO8859_9: Encoding
|
513
|
-
|
514
|
-
Encoding::ISO_2022_JP: Encoding
|
515
|
-
|
516
|
-
Encoding::ISO_2022_JP_2: Encoding
|
517
|
-
|
518
|
-
Encoding::ISO_2022_JP_KDDI: Encoding
|
519
|
-
|
520
|
-
Encoding::ISO_8859_1: Encoding
|
521
|
-
|
522
|
-
Encoding::ISO_8859_10: Encoding
|
523
|
-
|
524
|
-
Encoding::ISO_8859_11: Encoding
|
525
|
-
|
526
|
-
Encoding::ISO_8859_13: Encoding
|
527
|
-
|
528
|
-
Encoding::ISO_8859_14: Encoding
|
529
|
-
|
530
|
-
Encoding::ISO_8859_15: Encoding
|
531
|
-
|
532
|
-
Encoding::ISO_8859_16: Encoding
|
533
|
-
|
534
|
-
Encoding::ISO_8859_2: Encoding
|
535
|
-
|
536
|
-
Encoding::ISO_8859_3: Encoding
|
537
|
-
|
538
|
-
Encoding::ISO_8859_4: Encoding
|
539
|
-
|
540
|
-
Encoding::ISO_8859_5: Encoding
|
541
|
-
|
542
|
-
Encoding::ISO_8859_6: Encoding
|
543
|
-
|
544
|
-
Encoding::ISO_8859_7: Encoding
|
545
|
-
|
546
|
-
Encoding::ISO_8859_8: Encoding
|
547
|
-
|
548
|
-
Encoding::ISO_8859_9: Encoding
|
549
|
-
|
550
|
-
Encoding::KOI8_R: Encoding
|
551
|
-
|
552
|
-
Encoding::KOI8_U: Encoding
|
553
|
-
|
554
|
-
Encoding::MACCENTEURO: Encoding
|
555
|
-
|
556
|
-
Encoding::MACCROATIAN: Encoding
|
557
|
-
|
558
|
-
Encoding::MACCYRILLIC: Encoding
|
559
|
-
|
560
|
-
Encoding::MACGREEK: Encoding
|
561
|
-
|
562
|
-
Encoding::MACICELAND: Encoding
|
563
|
-
|
564
|
-
Encoding::MACJAPAN: Encoding
|
565
|
-
|
566
|
-
Encoding::MACJAPANESE: Encoding
|
567
|
-
|
568
|
-
Encoding::MACROMAN: Encoding
|
569
|
-
|
570
|
-
Encoding::MACROMANIA: Encoding
|
571
|
-
|
572
|
-
Encoding::MACTHAI: Encoding
|
573
|
-
|
574
|
-
Encoding::MACTURKISH: Encoding
|
575
|
-
|
576
|
-
Encoding::MACUKRAINE: Encoding
|
577
|
-
|
578
|
-
Encoding::MacCentEuro: Encoding
|
579
|
-
|
580
|
-
Encoding::MacCroatian: Encoding
|
581
|
-
|
582
|
-
Encoding::MacCyrillic: Encoding
|
583
|
-
|
584
|
-
Encoding::MacGreek: Encoding
|
585
|
-
|
586
|
-
Encoding::MacIceland: Encoding
|
587
|
-
|
588
|
-
Encoding::MacJapan: Encoding
|
589
|
-
|
590
|
-
Encoding::MacJapanese: Encoding
|
591
|
-
|
592
|
-
Encoding::MacRoman: Encoding
|
593
|
-
|
594
|
-
Encoding::MacRomania: Encoding
|
595
|
-
|
596
|
-
Encoding::MacThai: Encoding
|
597
|
-
|
598
|
-
Encoding::MacTurkish: Encoding
|
599
|
-
|
600
|
-
Encoding::MacUkraine: Encoding
|
601
|
-
|
602
|
-
Encoding::PCK: Encoding
|
603
|
-
|
604
|
-
Encoding::SHIFT_JIS: Encoding
|
605
|
-
|
606
|
-
Encoding::SJIS: Encoding
|
607
|
-
|
608
|
-
Encoding::SJIS_DOCOMO: Encoding
|
609
|
-
|
610
|
-
Encoding::SJIS_DoCoMo: Encoding
|
611
|
-
|
612
|
-
Encoding::SJIS_KDDI: Encoding
|
613
|
-
|
614
|
-
Encoding::SJIS_SOFTBANK: Encoding
|
615
|
-
|
616
|
-
Encoding::SJIS_SoftBank: Encoding
|
617
|
-
|
618
|
-
Encoding::STATELESS_ISO_2022_JP: Encoding
|
619
|
-
|
620
|
-
Encoding::STATELESS_ISO_2022_JP_KDDI: Encoding
|
621
|
-
|
622
|
-
Encoding::Shift_JIS: Encoding
|
623
|
-
|
624
|
-
Encoding::Stateless_ISO_2022_JP: Encoding
|
625
|
-
|
626
|
-
Encoding::Stateless_ISO_2022_JP_KDDI: Encoding
|
627
|
-
|
628
|
-
Encoding::TIS_620: Encoding
|
629
|
-
|
630
|
-
Encoding::UCS_2BE: Encoding
|
631
|
-
|
632
|
-
Encoding::UCS_4BE: Encoding
|
633
|
-
|
634
|
-
Encoding::UCS_4LE: Encoding
|
635
|
-
|
636
|
-
Encoding::US_ASCII: Encoding
|
637
|
-
|
638
|
-
Encoding::UTF8_DOCOMO: Encoding
|
639
|
-
|
640
|
-
Encoding::UTF8_DoCoMo: Encoding
|
641
|
-
|
642
|
-
Encoding::UTF8_KDDI: Encoding
|
643
|
-
|
644
|
-
Encoding::UTF8_MAC: Encoding
|
645
|
-
|
646
|
-
Encoding::UTF8_SOFTBANK: Encoding
|
647
|
-
|
648
|
-
Encoding::UTF8_SoftBank: Encoding
|
649
|
-
|
650
|
-
Encoding::UTF_16: Encoding
|
651
|
-
|
652
|
-
Encoding::UTF_16BE: Encoding
|
653
|
-
|
654
|
-
Encoding::UTF_16LE: Encoding
|
655
|
-
|
656
|
-
Encoding::UTF_32: Encoding
|
657
|
-
|
658
|
-
Encoding::UTF_32BE: Encoding
|
659
|
-
|
660
|
-
Encoding::UTF_32LE: Encoding
|
661
|
-
|
662
|
-
Encoding::UTF_7: Encoding
|
663
|
-
|
664
|
-
Encoding::UTF_8: Encoding
|
665
|
-
|
666
|
-
Encoding::UTF_8_HFS: Encoding
|
667
|
-
|
668
|
-
Encoding::UTF_8_MAC: Encoding
|
669
|
-
|
670
|
-
Encoding::WINDOWS_1250: Encoding
|
671
|
-
|
672
|
-
Encoding::WINDOWS_1251: Encoding
|
673
|
-
|
674
|
-
Encoding::WINDOWS_1252: Encoding
|
675
|
-
|
676
|
-
Encoding::WINDOWS_1253: Encoding
|
677
|
-
|
678
|
-
Encoding::WINDOWS_1254: Encoding
|
679
|
-
|
680
|
-
Encoding::WINDOWS_1255: Encoding
|
681
|
-
|
682
|
-
Encoding::WINDOWS_1256: Encoding
|
683
|
-
|
684
|
-
Encoding::WINDOWS_1257: Encoding
|
685
|
-
|
686
|
-
Encoding::WINDOWS_1258: Encoding
|
687
|
-
|
688
|
-
Encoding::WINDOWS_31J: Encoding
|
689
|
-
|
690
|
-
Encoding::WINDOWS_874: Encoding
|
691
|
-
|
692
|
-
Encoding::Windows_1250: Encoding
|
693
|
-
|
694
|
-
Encoding::Windows_1251: Encoding
|
695
|
-
|
696
|
-
Encoding::Windows_1252: Encoding
|
697
|
-
|
698
|
-
Encoding::Windows_1253: Encoding
|
699
|
-
|
700
|
-
Encoding::Windows_1254: Encoding
|
701
|
-
|
702
|
-
Encoding::Windows_1255: Encoding
|
703
|
-
|
704
|
-
Encoding::Windows_1256: Encoding
|
705
|
-
|
706
|
-
Encoding::Windows_1257: Encoding
|
707
|
-
|
708
|
-
Encoding::Windows_1258: Encoding
|
709
|
-
|
710
|
-
Encoding::Windows_31J: Encoding
|
711
|
-
|
712
|
-
Encoding::Windows_874: Encoding
|
713
|
-
|
714
708
|
# <!-- rdoc-file=transcode.c -->
|
715
709
|
# Encoding conversion class.
|
716
710
|
#
|
@@ -1397,191 +1391,3 @@ Encoding::Converter::XML_ATTR_QUOTE_DECORATOR: Integer
|
|
1397
1391
|
# Escape as XML CharData
|
1398
1392
|
#
|
1399
1393
|
Encoding::Converter::XML_TEXT_DECORATOR: Integer
|
1400
|
-
|
1401
|
-
# <!-- rdoc-file=error.c -->
|
1402
|
-
# Raised by Encoding and String methods when the source encoding is incompatible
|
1403
|
-
# with the target encoding.
|
1404
|
-
#
|
1405
|
-
class Encoding::CompatibilityError < EncodingError
|
1406
|
-
end
|
1407
|
-
|
1408
|
-
# <!-- rdoc-file=transcode.c -->
|
1409
|
-
# Raised by transcoding methods when a named encoding does not correspond with a
|
1410
|
-
# known converter.
|
1411
|
-
#
|
1412
|
-
class Encoding::ConverterNotFoundError < EncodingError
|
1413
|
-
end
|
1414
|
-
|
1415
|
-
# <!-- rdoc-file=transcode.c -->
|
1416
|
-
# Raised by Encoding and String methods when the string being transcoded
|
1417
|
-
# contains a byte invalid for the either the source or target encoding.
|
1418
|
-
#
|
1419
|
-
class Encoding::InvalidByteSequenceError < EncodingError
|
1420
|
-
public
|
1421
|
-
|
1422
|
-
# <!--
|
1423
|
-
# rdoc-file=transcode.c
|
1424
|
-
# - ecerr.destination_encoding -> string
|
1425
|
-
# -->
|
1426
|
-
# Returns the destination encoding as an encoding object.
|
1427
|
-
#
|
1428
|
-
def destination_encoding: () -> Encoding
|
1429
|
-
|
1430
|
-
# <!--
|
1431
|
-
# rdoc-file=transcode.c
|
1432
|
-
# - ecerr.destination_encoding_name -> string
|
1433
|
-
# -->
|
1434
|
-
# Returns the destination encoding name as a string.
|
1435
|
-
#
|
1436
|
-
def destination_encoding_name: () -> String
|
1437
|
-
|
1438
|
-
# <!--
|
1439
|
-
# rdoc-file=transcode.c
|
1440
|
-
# - ecerr.error_bytes -> string
|
1441
|
-
# -->
|
1442
|
-
# Returns the discarded bytes when Encoding::InvalidByteSequenceError occurs.
|
1443
|
-
#
|
1444
|
-
# ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
1445
|
-
# begin
|
1446
|
-
# ec.convert("abc\xA1\xFFdef")
|
1447
|
-
# rescue Encoding::InvalidByteSequenceError
|
1448
|
-
# p $! #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
|
1449
|
-
# puts $!.error_bytes.dump #=> "\xA1"
|
1450
|
-
# puts $!.readagain_bytes.dump #=> "\xFF"
|
1451
|
-
# end
|
1452
|
-
#
|
1453
|
-
def error_bytes: () -> String
|
1454
|
-
|
1455
|
-
# <!--
|
1456
|
-
# rdoc-file=transcode.c
|
1457
|
-
# - ecerr.incomplete_input? -> true or false
|
1458
|
-
# -->
|
1459
|
-
# Returns true if the invalid byte sequence error is caused by premature end of
|
1460
|
-
# string.
|
1461
|
-
#
|
1462
|
-
# ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
1463
|
-
#
|
1464
|
-
# begin
|
1465
|
-
# ec.convert("abc\xA1z")
|
1466
|
-
# rescue Encoding::InvalidByteSequenceError
|
1467
|
-
# p $! #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "z" on EUC-JP>
|
1468
|
-
# p $!.incomplete_input? #=> false
|
1469
|
-
# end
|
1470
|
-
#
|
1471
|
-
# begin
|
1472
|
-
# ec.convert("abc\xA1")
|
1473
|
-
# ec.finish
|
1474
|
-
# rescue Encoding::InvalidByteSequenceError
|
1475
|
-
# p $! #=> #<Encoding::InvalidByteSequenceError: incomplete "\xA1" on EUC-JP>
|
1476
|
-
# p $!.incomplete_input? #=> true
|
1477
|
-
# end
|
1478
|
-
#
|
1479
|
-
def incomplete_input?: () -> bool
|
1480
|
-
|
1481
|
-
# <!--
|
1482
|
-
# rdoc-file=transcode.c
|
1483
|
-
# - ecerr.readagain_bytes -> string
|
1484
|
-
# -->
|
1485
|
-
# Returns the bytes to be read again when Encoding::InvalidByteSequenceError
|
1486
|
-
# occurs.
|
1487
|
-
#
|
1488
|
-
def readagain_bytes: () -> String
|
1489
|
-
|
1490
|
-
# <!--
|
1491
|
-
# rdoc-file=transcode.c
|
1492
|
-
# - ecerr.source_encoding -> encoding
|
1493
|
-
# -->
|
1494
|
-
# Returns the source encoding as an encoding object.
|
1495
|
-
#
|
1496
|
-
# Note that the result may not be equal to the source encoding of the encoding
|
1497
|
-
# converter if the conversion has multiple steps.
|
1498
|
-
#
|
1499
|
-
# ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP
|
1500
|
-
# begin
|
1501
|
-
# ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP.
|
1502
|
-
# rescue Encoding::UndefinedConversionError
|
1503
|
-
# p $!.source_encoding #=> #<Encoding:UTF-8>
|
1504
|
-
# p $!.destination_encoding #=> #<Encoding:EUC-JP>
|
1505
|
-
# p $!.source_encoding_name #=> "UTF-8"
|
1506
|
-
# p $!.destination_encoding_name #=> "EUC-JP"
|
1507
|
-
# end
|
1508
|
-
#
|
1509
|
-
def source_encoding: () -> Encoding
|
1510
|
-
|
1511
|
-
# <!--
|
1512
|
-
# rdoc-file=transcode.c
|
1513
|
-
# - ecerr.source_encoding_name -> string
|
1514
|
-
# -->
|
1515
|
-
# Returns the source encoding name as a string.
|
1516
|
-
#
|
1517
|
-
def source_encoding_name: () -> String
|
1518
|
-
end
|
1519
|
-
|
1520
|
-
# <!-- rdoc-file=transcode.c -->
|
1521
|
-
# Raised by Encoding and String methods when a transcoding operation fails.
|
1522
|
-
#
|
1523
|
-
class Encoding::UndefinedConversionError < EncodingError
|
1524
|
-
public
|
1525
|
-
|
1526
|
-
# <!--
|
1527
|
-
# rdoc-file=transcode.c
|
1528
|
-
# - ecerr.destination_encoding -> string
|
1529
|
-
# -->
|
1530
|
-
# Returns the destination encoding as an encoding object.
|
1531
|
-
#
|
1532
|
-
def destination_encoding: () -> Encoding
|
1533
|
-
|
1534
|
-
# <!--
|
1535
|
-
# rdoc-file=transcode.c
|
1536
|
-
# - ecerr.destination_encoding_name -> string
|
1537
|
-
# -->
|
1538
|
-
# Returns the destination encoding name as a string.
|
1539
|
-
#
|
1540
|
-
def destination_encoding_name: () -> String
|
1541
|
-
|
1542
|
-
# <!--
|
1543
|
-
# rdoc-file=transcode.c
|
1544
|
-
# - ecerr.error_char -> string
|
1545
|
-
# -->
|
1546
|
-
# Returns the one-character string which cause
|
1547
|
-
# Encoding::UndefinedConversionError.
|
1548
|
-
#
|
1549
|
-
# ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
|
1550
|
-
# begin
|
1551
|
-
# ec.convert("\xa0")
|
1552
|
-
# rescue Encoding::UndefinedConversionError
|
1553
|
-
# puts $!.error_char.dump #=> "\xC2\xA0"
|
1554
|
-
# p $!.error_char.encoding #=> #<Encoding:UTF-8>
|
1555
|
-
# end
|
1556
|
-
#
|
1557
|
-
def error_char: () -> String
|
1558
|
-
|
1559
|
-
# <!--
|
1560
|
-
# rdoc-file=transcode.c
|
1561
|
-
# - ecerr.source_encoding -> encoding
|
1562
|
-
# -->
|
1563
|
-
# Returns the source encoding as an encoding object.
|
1564
|
-
#
|
1565
|
-
# Note that the result may not be equal to the source encoding of the encoding
|
1566
|
-
# converter if the conversion has multiple steps.
|
1567
|
-
#
|
1568
|
-
# ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP
|
1569
|
-
# begin
|
1570
|
-
# ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP.
|
1571
|
-
# rescue Encoding::UndefinedConversionError
|
1572
|
-
# p $!.source_encoding #=> #<Encoding:UTF-8>
|
1573
|
-
# p $!.destination_encoding #=> #<Encoding:EUC-JP>
|
1574
|
-
# p $!.source_encoding_name #=> "UTF-8"
|
1575
|
-
# p $!.destination_encoding_name #=> "EUC-JP"
|
1576
|
-
# end
|
1577
|
-
#
|
1578
|
-
def source_encoding: () -> Encoding
|
1579
|
-
|
1580
|
-
# <!--
|
1581
|
-
# rdoc-file=transcode.c
|
1582
|
-
# - ecerr.source_encoding_name -> string
|
1583
|
-
# -->
|
1584
|
-
# Returns the source encoding name as a string.
|
1585
|
-
#
|
1586
|
-
def source_encoding_name: () -> String
|
1587
|
-
end
|