rbs-relaxed 3.9.0.1
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 +7 -0
- data/.github/dependabot.yml +22 -0
- data/.github/workflows/comments.yml +35 -0
- data/.github/workflows/dependabot.yml +30 -0
- data/.github/workflows/ruby.yml +82 -0
- data/.github/workflows/typecheck.yml +38 -0
- data/.github/workflows/windows.yml +43 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +68 -0
- data/BSDL +22 -0
- data/CHANGELOG.md +1868 -0
- data/COPYING +56 -0
- data/README.md +203 -0
- data/Rakefile +417 -0
- data/Steepfile +44 -0
- data/config.yml +313 -0
- data/core/array.rbs +4062 -0
- data/core/basic_object.rbs +375 -0
- data/core/binding.rbs +150 -0
- data/core/builtin.rbs +277 -0
- data/core/class.rbs +220 -0
- data/core/comparable.rbs +171 -0
- data/core/complex.rbs +786 -0
- data/core/constants.rbs +96 -0
- data/core/data.rbs +415 -0
- data/core/dir.rbs +981 -0
- data/core/encoding.rbs +1371 -0
- data/core/enumerable.rbs +2405 -0
- data/core/enumerator/product.rbs +92 -0
- data/core/enumerator.rbs +630 -0
- data/core/env.rbs +6 -0
- data/core/errno.rbs +673 -0
- data/core/errors.rbs +760 -0
- data/core/exception.rbs +485 -0
- data/core/false_class.rbs +82 -0
- data/core/fiber.rbs +550 -0
- data/core/fiber_error.rbs +11 -0
- data/core/file.rbs +2936 -0
- data/core/file_test.rbs +331 -0
- data/core/float.rbs +1151 -0
- data/core/gc.rbs +644 -0
- data/core/global_variables.rbs +184 -0
- data/core/hash.rbs +1861 -0
- data/core/integer.rbs +1413 -0
- data/core/io/buffer.rbs +984 -0
- data/core/io/wait.rbs +70 -0
- data/core/io.rbs +3406 -0
- data/core/kernel.rbs +3096 -0
- data/core/marshal.rbs +207 -0
- data/core/match_data.rbs +635 -0
- data/core/math.rbs +729 -0
- data/core/method.rbs +386 -0
- data/core/module.rbs +1704 -0
- data/core/nil_class.rbs +209 -0
- data/core/numeric.rbs +818 -0
- data/core/object.rbs +110 -0
- data/core/object_space/weak_key_map.rbs +166 -0
- data/core/object_space.rbs +190 -0
- data/core/proc.rbs +868 -0
- data/core/process.rbs +2296 -0
- data/core/ractor.rbs +1068 -0
- data/core/random.rbs +237 -0
- data/core/range.rbs +1107 -0
- data/core/rational.rbs +531 -0
- data/core/rb_config.rbs +88 -0
- data/core/rbs/unnamed/argf.rbs +1229 -0
- data/core/rbs/unnamed/env_class.rbs +1209 -0
- data/core/rbs/unnamed/random.rbs +293 -0
- data/core/refinement.rbs +59 -0
- data/core/regexp.rbs +1930 -0
- data/core/ruby_vm.rbs +765 -0
- data/core/rubygems/basic_specification.rbs +6 -0
- data/core/rubygems/config_file.rbs +38 -0
- data/core/rubygems/dependency_installer.rbs +6 -0
- data/core/rubygems/errors.rbs +176 -0
- data/core/rubygems/installer.rbs +15 -0
- data/core/rubygems/path_support.rbs +6 -0
- data/core/rubygems/platform.rbs +7 -0
- data/core/rubygems/request_set.rbs +49 -0
- data/core/rubygems/requirement.rbs +148 -0
- data/core/rubygems/rubygems.rbs +1171 -0
- data/core/rubygems/source_list.rbs +15 -0
- data/core/rubygems/specification.rbs +23 -0
- data/core/rubygems/stream_ui.rbs +5 -0
- data/core/rubygems/uninstaller.rbs +10 -0
- data/core/rubygems/version.rbs +294 -0
- data/core/set.rbs +621 -0
- data/core/signal.rbs +100 -0
- data/core/string.rbs +3583 -0
- data/core/struct.rbs +667 -0
- data/core/symbol.rbs +475 -0
- data/core/thread.rbs +1765 -0
- data/core/thread_group.rbs +79 -0
- data/core/time.rbs +1762 -0
- data/core/trace_point.rbs +477 -0
- data/core/true_class.rbs +98 -0
- data/core/unbound_method.rbs +329 -0
- data/core/warning.rbs +87 -0
- data/docs/CONTRIBUTING.md +106 -0
- data/docs/architecture.md +110 -0
- data/docs/collection.md +192 -0
- data/docs/data_and_struct.md +86 -0
- data/docs/gem.md +57 -0
- data/docs/rbs_by_example.md +309 -0
- data/docs/repo.md +125 -0
- data/docs/sigs.md +167 -0
- data/docs/stdlib.md +147 -0
- data/docs/syntax.md +910 -0
- data/docs/tools.md +17 -0
- data/exe/rbs +7 -0
- data/ext/rbs_extension/extconf.rb +15 -0
- data/ext/rbs_extension/lexer.c +2728 -0
- data/ext/rbs_extension/lexer.h +179 -0
- data/ext/rbs_extension/lexer.re +147 -0
- data/ext/rbs_extension/lexstate.c +175 -0
- data/ext/rbs_extension/location.c +325 -0
- data/ext/rbs_extension/location.h +85 -0
- data/ext/rbs_extension/main.c +33 -0
- data/ext/rbs_extension/parser.c +2973 -0
- data/ext/rbs_extension/parser.h +18 -0
- data/ext/rbs_extension/parserstate.c +397 -0
- data/ext/rbs_extension/parserstate.h +163 -0
- data/ext/rbs_extension/rbs_extension.h +31 -0
- data/ext/rbs_extension/unescape.c +32 -0
- data/goodcheck.yml +91 -0
- data/include/rbs/constants.h +82 -0
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/ancestor_graph.rb +92 -0
- data/lib/rbs/annotate/annotations.rb +199 -0
- data/lib/rbs/annotate/formatter.rb +92 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +400 -0
- data/lib/rbs/annotate/rdoc_source.rb +131 -0
- data/lib/rbs/annotate.rb +8 -0
- data/lib/rbs/ast/annotation.rb +29 -0
- data/lib/rbs/ast/comment.rb +29 -0
- data/lib/rbs/ast/declarations.rb +467 -0
- data/lib/rbs/ast/directives.rb +49 -0
- data/lib/rbs/ast/members.rb +451 -0
- data/lib/rbs/ast/type_param.rb +225 -0
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +67 -0
- data/lib/rbs/builtin_names.rb +58 -0
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +83 -0
- data/lib/rbs/cli/validate.rb +357 -0
- data/lib/rbs/cli.rb +1223 -0
- data/lib/rbs/collection/cleaner.rb +38 -0
- data/lib/rbs/collection/config/lockfile.rb +92 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +218 -0
- data/lib/rbs/collection/config.rb +81 -0
- data/lib/rbs/collection/installer.rb +32 -0
- data/lib/rbs/collection/sources/base.rb +14 -0
- data/lib/rbs/collection/sources/git.rb +258 -0
- data/lib/rbs/collection/sources/local.rb +81 -0
- data/lib/rbs/collection/sources/rubygems.rb +48 -0
- data/lib/rbs/collection/sources/stdlib.rb +50 -0
- data/lib/rbs/collection/sources.rb +38 -0
- data/lib/rbs/collection.rb +16 -0
- data/lib/rbs/constant.rb +28 -0
- data/lib/rbs/definition.rb +401 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +620 -0
- data/lib/rbs/definition_builder/method_builder.rb +254 -0
- data/lib/rbs/definition_builder.rb +845 -0
- data/lib/rbs/diff.rb +125 -0
- data/lib/rbs/environment/use_map.rb +77 -0
- data/lib/rbs/environment.rb +829 -0
- data/lib/rbs/environment_loader.rb +173 -0
- data/lib/rbs/environment_walker.rb +155 -0
- data/lib/rbs/errors.rb +645 -0
- data/lib/rbs/factory.rb +18 -0
- data/lib/rbs/file_finder.rb +28 -0
- data/lib/rbs/location_aux.rb +138 -0
- data/lib/rbs/locator.rb +243 -0
- data/lib/rbs/method_type.rb +143 -0
- data/lib/rbs/namespace.rb +125 -0
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +114 -0
- data/lib/rbs/prototype/helpers.rb +140 -0
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +840 -0
- data/lib/rbs/prototype/rbi.rb +641 -0
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
- data/lib/rbs/prototype/runtime.rb +667 -0
- data/lib/rbs/repository.rb +127 -0
- data/lib/rbs/resolver/constant_resolver.rb +219 -0
- data/lib/rbs/resolver/type_name_resolver.rb +91 -0
- data/lib/rbs/sorter.rb +198 -0
- data/lib/rbs/substitution.rb +83 -0
- data/lib/rbs/subtractor.rb +201 -0
- data/lib/rbs/test/errors.rb +80 -0
- data/lib/rbs/test/guaranteed.rb +30 -0
- data/lib/rbs/test/hook.rb +212 -0
- data/lib/rbs/test/observer.rb +19 -0
- data/lib/rbs/test/setup.rb +84 -0
- data/lib/rbs/test/setup_helper.rb +50 -0
- data/lib/rbs/test/tester.rb +167 -0
- data/lib/rbs/test/type_check.rb +435 -0
- data/lib/rbs/test.rb +112 -0
- data/lib/rbs/type_alias_dependency.rb +100 -0
- data/lib/rbs/type_alias_regularity.rb +126 -0
- data/lib/rbs/type_name.rb +109 -0
- data/lib/rbs/types.rb +1596 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +138 -0
- data/lib/rbs/unit_test/type_assertions.rb +347 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/validator.rb +186 -0
- data/lib/rbs/variance_calculator.rb +189 -0
- data/lib/rbs/vendorer.rb +71 -0
- data/lib/rbs/version.rb +5 -0
- data/lib/rbs/writer.rb +424 -0
- data/lib/rbs.rb +94 -0
- data/lib/rdoc/discover.rb +20 -0
- data/lib/rdoc_plugin/parser.rb +163 -0
- data/rbs-relaxed.gemspec +48 -0
- data/schema/annotation.json +14 -0
- data/schema/comment.json +26 -0
- data/schema/decls.json +326 -0
- data/schema/function.json +87 -0
- data/schema/location.json +56 -0
- data/schema/members.json +266 -0
- data/schema/methodType.json +50 -0
- data/schema/typeParam.json +36 -0
- data/schema/types.json +317 -0
- data/sig/ancestor_builder.rbs +163 -0
- data/sig/ancestor_graph.rbs +60 -0
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/annotation.rbs +27 -0
- data/sig/buffer.rbs +32 -0
- data/sig/builtin_names.rbs +44 -0
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli/validate.rbs +43 -0
- data/sig/cli.rbs +87 -0
- data/sig/collection/cleaner.rbs +13 -0
- data/sig/collection/config/lockfile.rbs +74 -0
- data/sig/collection/config/lockfile_generator.rbs +66 -0
- data/sig/collection/config.rbs +46 -0
- data/sig/collection/installer.rbs +17 -0
- data/sig/collection/sources.rbs +214 -0
- data/sig/collection.rbs +4 -0
- data/sig/comment.rbs +26 -0
- data/sig/constant.rbs +21 -0
- data/sig/declarations.rbs +267 -0
- data/sig/definition.rbs +173 -0
- data/sig/definition_builder.rbs +165 -0
- data/sig/diff.rbs +28 -0
- data/sig/directives.rbs +77 -0
- data/sig/environment.rbs +279 -0
- data/sig/environment_loader.rbs +111 -0
- data/sig/environment_walker.rbs +65 -0
- data/sig/errors.rbs +405 -0
- data/sig/factory.rbs +5 -0
- data/sig/file_finder.rbs +28 -0
- data/sig/location.rbs +110 -0
- data/sig/locator.rbs +58 -0
- data/sig/manifest.yaml +7 -0
- data/sig/members.rbs +258 -0
- data/sig/method_builder.rbs +84 -0
- data/sig/method_types.rbs +58 -0
- data/sig/namespace.rbs +146 -0
- data/sig/parser.rbs +100 -0
- data/sig/prototype/helpers.rbs +27 -0
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/prototype/rb.rbs +96 -0
- data/sig/prototype/rbi.rbs +75 -0
- data/sig/prototype/runtime.rbs +182 -0
- data/sig/rbs.rbs +21 -0
- data/sig/rdoc/rbs.rbs +67 -0
- data/sig/repository.rbs +85 -0
- data/sig/resolver/constant_resolver.rbs +92 -0
- data/sig/resolver/context.rbs +34 -0
- data/sig/resolver/type_name_resolver.rbs +35 -0
- data/sig/shims/bundler.rbs +38 -0
- data/sig/shims/enumerable.rbs +5 -0
- data/sig/shims/rubygems.rbs +19 -0
- data/sig/sorter.rbs +41 -0
- data/sig/substitution.rbs +48 -0
- data/sig/subtractor.rbs +37 -0
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/type_alias_dependency.rbs +53 -0
- data/sig/type_alias_regularity.rbs +98 -0
- data/sig/type_param.rbs +110 -0
- data/sig/typename.rbs +79 -0
- data/sig/types.rbs +579 -0
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +30 -0
- data/sig/unit_test/type_assertions.rbs +196 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/sig/use_map.rbs +35 -0
- data/sig/util.rbs +9 -0
- data/sig/validator.rbs +63 -0
- data/sig/variance_calculator.rbs +87 -0
- data/sig/vendorer.rbs +51 -0
- data/sig/version.rbs +3 -0
- data/sig/visitor.rbs +47 -0
- data/sig/writer.rbs +127 -0
- data/src/constants.c +153 -0
- data/src/ruby_objs.c +795 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/abbrev/0/abbrev.rbs +66 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +355 -0
- data/stdlib/benchmark/0/benchmark.rbs +452 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +1629 -0
- data/stdlib/bigdecimal-math/0/big_math.rbs +119 -0
- data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
- data/stdlib/cgi/0/core.rbs +1285 -0
- data/stdlib/cgi/0/manifest.yaml +3 -0
- data/stdlib/coverage/0/coverage.rbs +263 -0
- data/stdlib/csv/0/csv.rbs +3776 -0
- data/stdlib/csv/0/manifest.yaml +3 -0
- data/stdlib/date/0/date.rbs +1585 -0
- data/stdlib/date/0/date_time.rbs +616 -0
- data/stdlib/date/0/time.rbs +26 -0
- data/stdlib/dbm/0/dbm.rbs +421 -0
- data/stdlib/delegate/0/delegator.rbs +184 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +96 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +343 -0
- data/stdlib/digest/0/digest.rbs +577 -0
- data/stdlib/erb/0/erb.rbs +532 -0
- data/stdlib/etc/0/etc.rbs +865 -0
- data/stdlib/fileutils/0/fileutils.rbs +1734 -0
- data/stdlib/find/0/find.rbs +49 -0
- data/stdlib/forwardable/0/forwardable.rbs +268 -0
- data/stdlib/io-console/0/io-console.rbs +414 -0
- data/stdlib/ipaddr/0/ipaddr.rbs +428 -0
- data/stdlib/json/0/json.rbs +1916 -0
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/logger/0/formatter.rbs +45 -0
- data/stdlib/logger/0/log_device.rbs +100 -0
- data/stdlib/logger/0/logger.rbs +796 -0
- data/stdlib/logger/0/manifest.yaml +2 -0
- data/stdlib/logger/0/period.rbs +17 -0
- data/stdlib/logger/0/severity.rbs +34 -0
- data/stdlib/minitest/0/kernel.rbs +42 -0
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
- data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
- data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
- data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
- data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
- data/stdlib/minitest/0/minitest/guard.rbs +64 -0
- data/stdlib/minitest/0/minitest/mock.rbs +64 -0
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
- data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
- data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
- data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
- data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
- data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/result.rbs +28 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
- data/stdlib/minitest/0/minitest/skip.rbs +6 -0
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
- data/stdlib/minitest/0/minitest/spec.rbs +11 -0
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
- data/stdlib/minitest/0/minitest/test.rbs +69 -0
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
- data/stdlib/minitest/0/minitest/unit.rbs +4 -0
- data/stdlib/minitest/0/minitest.rbs +115 -0
- data/stdlib/monitor/0/monitor.rbs +363 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
- data/stdlib/net-http/0/manifest.yaml +3 -0
- data/stdlib/net-http/0/net-http.rbs +5552 -0
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/nkf/0/nkf.rbs +402 -0
- data/stdlib/objspace/0/objspace.rbs +487 -0
- data/stdlib/observable/0/observable.rbs +217 -0
- data/stdlib/open-uri/0/manifest.yaml +4 -0
- data/stdlib/open-uri/0/open-uri.rbs +393 -0
- data/stdlib/open3/0/open3.rbs +147 -0
- data/stdlib/openssl/0/manifest.yaml +3 -0
- data/stdlib/openssl/0/openssl.rbs +12113 -0
- data/stdlib/optparse/0/optparse.rbs +1725 -0
- data/stdlib/pathname/0/pathname.rbs +1406 -0
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +300 -0
- data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
- data/stdlib/pstore/0/pstore.rbs +603 -0
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/dbm.rbs +237 -0
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +402 -0
- data/stdlib/psych/0/store.rbs +59 -0
- data/stdlib/pty/0/pty.rbs +237 -0
- data/stdlib/rdoc/0/code_object.rbs +51 -0
- data/stdlib/rdoc/0/comment.rbs +59 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +117 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +391 -0
- 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/resolv/0/manifest.yaml +3 -0
- data/stdlib/resolv/0/resolv.rbs +1830 -0
- data/stdlib/ripper/0/ripper.rbs +1648 -0
- data/stdlib/securerandom/0/securerandom.rbs +62 -0
- data/stdlib/shellwords/0/shellwords.rbs +229 -0
- data/stdlib/singleton/0/singleton.rbs +131 -0
- data/stdlib/socket/0/addrinfo.rbs +666 -0
- data/stdlib/socket/0/basic_socket.rbs +590 -0
- data/stdlib/socket/0/constants.rbs +2295 -0
- data/stdlib/socket/0/ip_socket.rbs +92 -0
- data/stdlib/socket/0/socket.rbs +4157 -0
- data/stdlib/socket/0/socket_error.rbs +5 -0
- data/stdlib/socket/0/tcp_server.rbs +192 -0
- data/stdlib/socket/0/tcp_socket.rbs +79 -0
- data/stdlib/socket/0/udp_socket.rbs +133 -0
- data/stdlib/socket/0/unix_server.rbs +169 -0
- data/stdlib/socket/0/unix_socket.rbs +172 -0
- data/stdlib/stringio/0/stringio.rbs +567 -0
- data/stdlib/strscan/0/string_scanner.rbs +1627 -0
- data/stdlib/tempfile/0/tempfile.rbs +479 -0
- data/stdlib/time/0/time.rbs +432 -0
- data/stdlib/timeout/0/timeout.rbs +81 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
- data/stdlib/tsort/0/cyclic.rbs +5 -0
- data/stdlib/tsort/0/interfaces.rbs +20 -0
- data/stdlib/tsort/0/tsort.rbs +409 -0
- data/stdlib/uri/0/common.rbs +582 -0
- data/stdlib/uri/0/file.rbs +118 -0
- data/stdlib/uri/0/ftp.rbs +13 -0
- data/stdlib/uri/0/generic.rbs +1108 -0
- data/stdlib/uri/0/http.rbs +104 -0
- data/stdlib/uri/0/https.rbs +14 -0
- data/stdlib/uri/0/ldap.rbs +230 -0
- data/stdlib/uri/0/ldaps.rbs +14 -0
- data/stdlib/uri/0/mailto.rbs +92 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
- data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
- data/stdlib/uri/0/ws.rbs +13 -0
- data/stdlib/uri/0/wss.rbs +9 -0
- data/stdlib/yaml/0/manifest.yaml +2 -0
- data/stdlib/yaml/0/yaml.rbs +1 -0
- data/stdlib/zlib/0/buf_error.rbs +10 -0
- data/stdlib/zlib/0/data_error.rbs +10 -0
- data/stdlib/zlib/0/deflate.rbs +210 -0
- data/stdlib/zlib/0/error.rbs +20 -0
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
- data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
- data/stdlib/zlib/0/gzip_file.rbs +156 -0
- data/stdlib/zlib/0/gzip_reader.rbs +293 -0
- data/stdlib/zlib/0/gzip_writer.rbs +166 -0
- data/stdlib/zlib/0/inflate.rbs +180 -0
- data/stdlib/zlib/0/mem_error.rbs +10 -0
- data/stdlib/zlib/0/need_dict.rbs +13 -0
- data/stdlib/zlib/0/stream_end.rbs +11 -0
- data/stdlib/zlib/0/stream_error.rbs +11 -0
- data/stdlib/zlib/0/version_error.rbs +11 -0
- data/stdlib/zlib/0/zlib.rbs +449 -0
- data/stdlib/zlib/0/zstream.rbs +200 -0
- metadata +532 -0
data/core/encoding.rbs
ADDED
@@ -0,0 +1,1371 @@
|
|
1
|
+
# <!-- rdoc-file=encoding.c -->
|
2
|
+
# An Encoding instance represents a character encoding usable in Ruby. It is
|
3
|
+
# defined as a constant under the Encoding namespace. It has a name and,
|
4
|
+
# optionally, aliases:
|
5
|
+
#
|
6
|
+
# Encoding::US_ASCII.name # => "US-ASCII"
|
7
|
+
# Encoding::US_ASCII.names # => ["US-ASCII", "ASCII", "ANSI_X3.4-1968", "646"]
|
8
|
+
#
|
9
|
+
# A Ruby method that accepts an encoding as an argument will accept:
|
10
|
+
#
|
11
|
+
# * An Encoding object.
|
12
|
+
# * The name of an encoding.
|
13
|
+
# * An alias for an encoding name.
|
14
|
+
#
|
15
|
+
# These are equivalent:
|
16
|
+
#
|
17
|
+
# 'foo'.encode(Encoding::US_ASCII) # Encoding object.
|
18
|
+
# 'foo'.encode('US-ASCII') # Encoding name.
|
19
|
+
# 'foo'.encode('ASCII') # Encoding alias.
|
20
|
+
#
|
21
|
+
# For a full discussion of encodings and their uses, see [the Encodings
|
22
|
+
# document](rdoc-ref:encodings.rdoc).
|
23
|
+
#
|
24
|
+
# Encoding::ASCII_8BIT is a special-purpose encoding that is usually used for a
|
25
|
+
# string of bytes, not a string of characters. But as the name indicates, its
|
26
|
+
# characters in the ASCII range are considered as ASCII characters. This is
|
27
|
+
# useful when you use other ASCII-compatible encodings.
|
28
|
+
#
|
29
|
+
class Encoding
|
30
|
+
def self._load: [T] (T) -> T
|
31
|
+
|
32
|
+
# <!--
|
33
|
+
# rdoc-file=encoding.c
|
34
|
+
# - Encoding.locale_charmap -> string
|
35
|
+
# -->
|
36
|
+
# Returns the locale charmap name. It returns nil if no appropriate information.
|
37
|
+
#
|
38
|
+
# Debian GNU/Linux
|
39
|
+
# LANG=C
|
40
|
+
# Encoding.locale_charmap #=> "ANSI_X3.4-1968"
|
41
|
+
# LANG=ja_JP.EUC-JP
|
42
|
+
# Encoding.locale_charmap #=> "EUC-JP"
|
43
|
+
#
|
44
|
+
# SunOS 5
|
45
|
+
# LANG=C
|
46
|
+
# Encoding.locale_charmap #=> "646"
|
47
|
+
# LANG=ja
|
48
|
+
# Encoding.locale_charmap #=> "eucJP"
|
49
|
+
#
|
50
|
+
# The result is highly platform dependent. So
|
51
|
+
# Encoding.find(Encoding.locale_charmap) may cause an error. If you need some
|
52
|
+
# encoding object even for unknown locale, Encoding.find("locale") can be used.
|
53
|
+
#
|
54
|
+
def self.locale_charmap: () -> String
|
55
|
+
|
56
|
+
# <!--
|
57
|
+
# rdoc-file=encoding.c
|
58
|
+
# - Encoding.aliases -> {"alias1" => "orig1", "alias2" => "orig2", ...}
|
59
|
+
# -->
|
60
|
+
# Returns the hash of available encoding alias and original encoding name.
|
61
|
+
#
|
62
|
+
# Encoding.aliases
|
63
|
+
# #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1968"=>"US-ASCII",
|
64
|
+
# "SJIS"=>"Windows-31J", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
|
65
|
+
#
|
66
|
+
def self.aliases: () -> Hash[String, String]
|
67
|
+
|
68
|
+
# <!--
|
69
|
+
# rdoc-file=encoding.c
|
70
|
+
# - Encoding.compatible?(obj1, obj2) -> enc or nil
|
71
|
+
# -->
|
72
|
+
# Checks the compatibility of two objects.
|
73
|
+
#
|
74
|
+
# If the objects are both strings they are compatible when they are
|
75
|
+
# concatenatable. The encoding of the concatenated string will be returned if
|
76
|
+
# they are compatible, nil if they are not.
|
77
|
+
#
|
78
|
+
# Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b")
|
79
|
+
# #=> #<Encoding:ISO-8859-1>
|
80
|
+
#
|
81
|
+
# Encoding.compatible?(
|
82
|
+
# "\xa1".force_encoding("iso-8859-1"),
|
83
|
+
# "\xa1\xa1".force_encoding("euc-jp"))
|
84
|
+
# #=> nil
|
85
|
+
#
|
86
|
+
# If the objects are non-strings their encodings are compatible when they have
|
87
|
+
# an encoding and:
|
88
|
+
# * Either encoding is US-ASCII compatible
|
89
|
+
# * One of the encodings is a 7-bit encoding
|
90
|
+
#
|
91
|
+
def self.compatible?: (untyped obj1, untyped obj2) -> Encoding?
|
92
|
+
|
93
|
+
# <!--
|
94
|
+
# rdoc-file=encoding.c
|
95
|
+
# - Encoding.default_external -> enc
|
96
|
+
# -->
|
97
|
+
# Returns default external encoding.
|
98
|
+
#
|
99
|
+
# The default external encoding is used by default for strings created from the
|
100
|
+
# following locations:
|
101
|
+
#
|
102
|
+
# * CSV
|
103
|
+
# * File data read from disk
|
104
|
+
# * SDBM
|
105
|
+
# * StringIO
|
106
|
+
# * Zlib::GzipReader
|
107
|
+
# * Zlib::GzipWriter
|
108
|
+
# * String#inspect
|
109
|
+
# * Regexp#inspect
|
110
|
+
#
|
111
|
+
# While strings created from these locations will have this encoding, the
|
112
|
+
# encoding may not be valid. Be sure to check String#valid_encoding?.
|
113
|
+
#
|
114
|
+
# File data written to disk will be transcoded to the default external encoding
|
115
|
+
# when written, if default_internal is not nil.
|
116
|
+
#
|
117
|
+
# The default external encoding is initialized by the -E option. If -E isn't
|
118
|
+
# set, it is initialized to UTF-8 on Windows and the locale on other operating
|
119
|
+
# systems.
|
120
|
+
#
|
121
|
+
def self.default_external: () -> Encoding
|
122
|
+
|
123
|
+
# <!--
|
124
|
+
# rdoc-file=encoding.c
|
125
|
+
# - Encoding.default_external = enc
|
126
|
+
# -->
|
127
|
+
# Sets default external encoding. You should not set Encoding::default_external
|
128
|
+
# in ruby code as strings created before changing the value may have a different
|
129
|
+
# encoding from strings created after the value was changed., instead you should
|
130
|
+
# use `ruby -E` to invoke ruby with the correct default_external.
|
131
|
+
#
|
132
|
+
# See Encoding::default_external for information on how the default external
|
133
|
+
# encoding is used.
|
134
|
+
#
|
135
|
+
def self.default_external=: (Encoding enc) -> Encoding
|
136
|
+
| [T < _ToStr] (T enc) -> T
|
137
|
+
|
138
|
+
# <!--
|
139
|
+
# rdoc-file=encoding.c
|
140
|
+
# - Encoding.default_internal -> enc
|
141
|
+
# -->
|
142
|
+
# Returns default internal encoding. Strings will be transcoded to the default
|
143
|
+
# internal encoding in the following places if the default internal encoding is
|
144
|
+
# not nil:
|
145
|
+
#
|
146
|
+
# * CSV
|
147
|
+
# * Etc.sysconfdir and Etc.systmpdir
|
148
|
+
# * File data read from disk
|
149
|
+
# * File names from Dir
|
150
|
+
# * Integer#chr
|
151
|
+
# * String#inspect and Regexp#inspect
|
152
|
+
# * Strings returned from Readline
|
153
|
+
# * Strings returned from SDBM
|
154
|
+
# * Time#zone
|
155
|
+
# * Values from ENV
|
156
|
+
# * Values in ARGV including $PROGRAM_NAME
|
157
|
+
#
|
158
|
+
# Additionally String#encode and String#encode! use the default internal
|
159
|
+
# encoding if no encoding is given.
|
160
|
+
#
|
161
|
+
# The script encoding (__ENCODING__), not default_internal, is used as the
|
162
|
+
# encoding of created strings.
|
163
|
+
#
|
164
|
+
# Encoding::default_internal is initialized with -E option or nil otherwise.
|
165
|
+
#
|
166
|
+
def self.default_internal: () -> Encoding?
|
167
|
+
|
168
|
+
# <!--
|
169
|
+
# rdoc-file=encoding.c
|
170
|
+
# - Encoding.default_internal = enc or nil
|
171
|
+
# -->
|
172
|
+
# Sets default internal encoding or removes default internal encoding when
|
173
|
+
# passed nil. You should not set Encoding::default_internal in ruby code as
|
174
|
+
# strings created before changing the value may have a different encoding from
|
175
|
+
# strings created after the change. Instead you should use `ruby -E` to invoke
|
176
|
+
# ruby with the correct default_internal.
|
177
|
+
#
|
178
|
+
# See Encoding::default_internal for information on how the default internal
|
179
|
+
# encoding is used.
|
180
|
+
#
|
181
|
+
def self.default_internal=: (Encoding enc) -> Encoding
|
182
|
+
| [T < _ToStr] (T enc) -> T
|
183
|
+
| (nil) -> nil
|
184
|
+
|
185
|
+
# <!--
|
186
|
+
# rdoc-file=encoding.c
|
187
|
+
# - Encoding.find(string) -> enc
|
188
|
+
# -->
|
189
|
+
# Search the encoding with specified *name*. *name* should be a string.
|
190
|
+
#
|
191
|
+
# Encoding.find("US-ASCII") #=> #<Encoding:US-ASCII>
|
192
|
+
#
|
193
|
+
# Names which this method accept are encoding names and aliases including
|
194
|
+
# following special aliases
|
195
|
+
#
|
196
|
+
# "external"
|
197
|
+
# : default external encoding
|
198
|
+
#
|
199
|
+
# "internal"
|
200
|
+
# : default internal encoding
|
201
|
+
#
|
202
|
+
# "locale"
|
203
|
+
# : locale encoding
|
204
|
+
#
|
205
|
+
# "filesystem"
|
206
|
+
# : filesystem encoding
|
207
|
+
#
|
208
|
+
#
|
209
|
+
# An ArgumentError is raised when no encoding with *name*. Only
|
210
|
+
# `Encoding.find("internal")` however returns nil when no encoding named
|
211
|
+
# "internal", in other words, when Ruby has no default internal encoding.
|
212
|
+
#
|
213
|
+
def self.find: (encoding enc) -> Encoding?
|
214
|
+
|
215
|
+
# <!--
|
216
|
+
# rdoc-file=encoding.c
|
217
|
+
# - Encoding.list -> [enc1, enc2, ...]
|
218
|
+
# -->
|
219
|
+
# Returns the list of loaded encodings.
|
220
|
+
#
|
221
|
+
# Encoding.list
|
222
|
+
# #=> [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>,
|
223
|
+
# #<Encoding:ISO-2022-JP (dummy)>]
|
224
|
+
#
|
225
|
+
# Encoding.find("US-ASCII")
|
226
|
+
# #=> #<Encoding:US-ASCII>
|
227
|
+
#
|
228
|
+
# Encoding.list
|
229
|
+
# #=> [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>,
|
230
|
+
# #<Encoding:US-ASCII>, #<Encoding:ISO-2022-JP (dummy)>]
|
231
|
+
#
|
232
|
+
def self.list: () -> Array[Encoding]
|
233
|
+
|
234
|
+
# <!--
|
235
|
+
# rdoc-file=encoding.c
|
236
|
+
# - Encoding.name_list -> ["enc1", "enc2", ...]
|
237
|
+
# -->
|
238
|
+
# Returns the list of available encoding names.
|
239
|
+
#
|
240
|
+
# Encoding.name_list
|
241
|
+
# #=> ["US-ASCII", "ASCII-8BIT", "UTF-8",
|
242
|
+
# "ISO-8859-1", "Shift_JIS", "EUC-JP",
|
243
|
+
# "Windows-31J",
|
244
|
+
# "BINARY", "CP932", "eucJP"]
|
245
|
+
#
|
246
|
+
def self.name_list: () -> Array[String]
|
247
|
+
|
248
|
+
# <!--
|
249
|
+
# rdoc-file=encoding.c
|
250
|
+
# - enc.ascii_compatible? -> true or false
|
251
|
+
# -->
|
252
|
+
# Returns whether ASCII-compatible or not.
|
253
|
+
#
|
254
|
+
# Encoding::UTF_8.ascii_compatible? #=> true
|
255
|
+
# Encoding::UTF_16BE.ascii_compatible? #=> false
|
256
|
+
#
|
257
|
+
def ascii_compatible?: () -> bool
|
258
|
+
|
259
|
+
# <!--
|
260
|
+
# rdoc-file=encoding.c
|
261
|
+
# - enc.dummy? -> true or false
|
262
|
+
# -->
|
263
|
+
# Returns true for dummy encodings. A dummy encoding is an encoding for which
|
264
|
+
# character handling is not properly implemented. It is used for stateful
|
265
|
+
# encodings.
|
266
|
+
#
|
267
|
+
# Encoding::ISO_2022_JP.dummy? #=> true
|
268
|
+
# Encoding::UTF_8.dummy? #=> false
|
269
|
+
#
|
270
|
+
def dummy?: () -> bool
|
271
|
+
|
272
|
+
# <!--
|
273
|
+
# rdoc-file=encoding.c
|
274
|
+
# - enc.inspect -> string
|
275
|
+
# -->
|
276
|
+
# Returns a string which represents the encoding for programmers.
|
277
|
+
#
|
278
|
+
# Encoding::UTF_8.inspect #=> "#<Encoding:UTF-8>"
|
279
|
+
# Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
|
280
|
+
#
|
281
|
+
def inspect: () -> String
|
282
|
+
|
283
|
+
# <!-- rdoc-file=encoding.c -->
|
284
|
+
# Returns the name of the encoding.
|
285
|
+
#
|
286
|
+
# Encoding::UTF_8.name #=> "UTF-8"
|
287
|
+
#
|
288
|
+
def name: () -> String
|
289
|
+
|
290
|
+
# <!--
|
291
|
+
# rdoc-file=encoding.c
|
292
|
+
# - enc.names -> array
|
293
|
+
# -->
|
294
|
+
# Returns the list of name and aliases of the encoding.
|
295
|
+
#
|
296
|
+
# Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"]
|
297
|
+
#
|
298
|
+
def names: () -> Array[String]
|
299
|
+
|
300
|
+
# <!--
|
301
|
+
# rdoc-file=encoding.c
|
302
|
+
# - enc.name -> string
|
303
|
+
# - enc.to_s -> string
|
304
|
+
# -->
|
305
|
+
# Returns the name of the encoding.
|
306
|
+
#
|
307
|
+
# Encoding::UTF_8.name #=> "UTF-8"
|
308
|
+
#
|
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
|
706
|
+
end
|
707
|
+
|
708
|
+
# <!-- rdoc-file=transcode.c -->
|
709
|
+
# Encoding conversion class.
|
710
|
+
#
|
711
|
+
class Encoding::Converter < Object
|
712
|
+
type encoding = String | Encoding
|
713
|
+
type decorator = "universal_newline"
|
714
|
+
| "crlf_newline"
|
715
|
+
| "cr_newline"
|
716
|
+
| "xml_text_escape"
|
717
|
+
| "xml_attr_content_escape"
|
718
|
+
| "xml_attr_quote"
|
719
|
+
type conversion_path = Array[[encoding, encoding] | decorator]
|
720
|
+
type convert_result = :invalid_byte_sequence
|
721
|
+
| :incomplete_input
|
722
|
+
| :undefined_conversion
|
723
|
+
| :after_output
|
724
|
+
| :destination_buffer_full
|
725
|
+
| :source_buffer_empty
|
726
|
+
| :finished
|
727
|
+
|
728
|
+
# <!--
|
729
|
+
# rdoc-file=transcode.c
|
730
|
+
# - Encoding::Converter.asciicompat_encoding(string) -> encoding or nil
|
731
|
+
# - Encoding::Converter.asciicompat_encoding(encoding) -> encoding or nil
|
732
|
+
# -->
|
733
|
+
# Returns the corresponding ASCII compatible encoding.
|
734
|
+
#
|
735
|
+
# Returns nil if the argument is an ASCII compatible encoding.
|
736
|
+
#
|
737
|
+
# "corresponding ASCII compatible encoding" is an ASCII compatible encoding
|
738
|
+
# which can represents exactly the same characters as the given ASCII
|
739
|
+
# incompatible encoding. So, no conversion undefined error occurs when
|
740
|
+
# converting between the two encodings.
|
741
|
+
#
|
742
|
+
# Encoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> #<Encoding:stateless-ISO-2022-JP>
|
743
|
+
# Encoding::Converter.asciicompat_encoding("UTF-16BE") #=> #<Encoding:UTF-8>
|
744
|
+
# Encoding::Converter.asciicompat_encoding("UTF-8") #=> nil
|
745
|
+
#
|
746
|
+
def self.asciicompat_encoding: (encoding enc) -> Encoding?
|
747
|
+
|
748
|
+
# <!--
|
749
|
+
# rdoc-file=transcode.c
|
750
|
+
# - Encoding::Converter.search_convpath(source_encoding, destination_encoding) -> ary
|
751
|
+
# - Encoding::Converter.search_convpath(source_encoding, destination_encoding, opt) -> ary
|
752
|
+
# -->
|
753
|
+
# Returns a conversion path.
|
754
|
+
#
|
755
|
+
# p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP")
|
756
|
+
# #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
|
757
|
+
# # [#<Encoding:UTF-8>, #<Encoding:EUC-JP>]]
|
758
|
+
#
|
759
|
+
# p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", universal_newline: true)
|
760
|
+
# or
|
761
|
+
# p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", newline: :universal)
|
762
|
+
# #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
|
763
|
+
# # [#<Encoding:UTF-8>, #<Encoding:EUC-JP>],
|
764
|
+
# # "universal_newline"]
|
765
|
+
#
|
766
|
+
# p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", universal_newline: true)
|
767
|
+
# or
|
768
|
+
# p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", newline: :universal)
|
769
|
+
# #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
|
770
|
+
# # "universal_newline",
|
771
|
+
# # [#<Encoding:UTF-8>, #<Encoding:UTF-32BE>]]
|
772
|
+
#
|
773
|
+
def self.search_convpath: (
|
774
|
+
encoding source,
|
775
|
+
encoding destination,
|
776
|
+
?newline: :universal | :crlf | :cr,
|
777
|
+
?universal_newline: bool,
|
778
|
+
?crlf_newline: bool,
|
779
|
+
?cr_newline: bool,
|
780
|
+
?xml: :text | :attr
|
781
|
+
) -> conversion_path
|
782
|
+
|
783
|
+
# <!--
|
784
|
+
# rdoc-file=transcode.c
|
785
|
+
# - ec == other -> true or false
|
786
|
+
# -->
|
787
|
+
#
|
788
|
+
def ==: (self) -> bool
|
789
|
+
|
790
|
+
# <!--
|
791
|
+
# rdoc-file=transcode.c
|
792
|
+
# - ec.convert(source_string) -> destination_string
|
793
|
+
# -->
|
794
|
+
# Convert source_string and return destination_string.
|
795
|
+
#
|
796
|
+
# source_string is assumed as a part of source. i.e. :partial_input=>true is
|
797
|
+
# specified internally. finish method should be used last.
|
798
|
+
#
|
799
|
+
# ec = Encoding::Converter.new("utf-8", "euc-jp")
|
800
|
+
# puts ec.convert("\u3042").dump #=> "\xA4\xA2"
|
801
|
+
# puts ec.finish.dump #=> ""
|
802
|
+
#
|
803
|
+
# ec = Encoding::Converter.new("euc-jp", "utf-8")
|
804
|
+
# puts ec.convert("\xA4").dump #=> ""
|
805
|
+
# puts ec.convert("\xA2").dump #=> "\xE3\x81\x82"
|
806
|
+
# puts ec.finish.dump #=> ""
|
807
|
+
#
|
808
|
+
# ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
|
809
|
+
# puts ec.convert("\xE3").dump #=> "".force_encoding("ISO-2022-JP")
|
810
|
+
# puts ec.convert("\x81").dump #=> "".force_encoding("ISO-2022-JP")
|
811
|
+
# puts ec.convert("\x82").dump #=> "\e$B$\"".force_encoding("ISO-2022-JP")
|
812
|
+
# puts ec.finish.dump #=> "\e(B".force_encoding("ISO-2022-JP")
|
813
|
+
#
|
814
|
+
# If a conversion error occur, Encoding::UndefinedConversionError or
|
815
|
+
# Encoding::InvalidByteSequenceError is raised. Encoding::Converter#convert
|
816
|
+
# doesn't supply methods to recover or restart from these exceptions. When you
|
817
|
+
# want to handle these conversion errors, use
|
818
|
+
# Encoding::Converter#primitive_convert.
|
819
|
+
#
|
820
|
+
def convert: (String source) -> String
|
821
|
+
|
822
|
+
# <!--
|
823
|
+
# rdoc-file=transcode.c
|
824
|
+
# - ec.convpath -> ary
|
825
|
+
# -->
|
826
|
+
# Returns the conversion path of ec.
|
827
|
+
#
|
828
|
+
# The result is an array of conversions.
|
829
|
+
#
|
830
|
+
# ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP", crlf_newline: true)
|
831
|
+
# p ec.convpath
|
832
|
+
# #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
|
833
|
+
# # [#<Encoding:UTF-8>, #<Encoding:EUC-JP>],
|
834
|
+
# # "crlf_newline"]
|
835
|
+
#
|
836
|
+
# Each element of the array is a pair of encodings or a string. A pair means an
|
837
|
+
# encoding conversion. A string means a decorator.
|
838
|
+
#
|
839
|
+
# In the above example, [#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>] means a
|
840
|
+
# converter from ISO-8859-1 to UTF-8. "crlf_newline" means newline converter
|
841
|
+
# from LF to CRLF.
|
842
|
+
#
|
843
|
+
def convpath: () -> conversion_path
|
844
|
+
|
845
|
+
# <!--
|
846
|
+
# rdoc-file=transcode.c
|
847
|
+
# - ec.destination_encoding -> encoding
|
848
|
+
# -->
|
849
|
+
# Returns the destination encoding as an Encoding object.
|
850
|
+
#
|
851
|
+
def destination_encoding: () -> Encoding
|
852
|
+
|
853
|
+
# <!--
|
854
|
+
# rdoc-file=transcode.c
|
855
|
+
# - ec.finish -> string
|
856
|
+
# -->
|
857
|
+
# Finishes the converter. It returns the last part of the converted string.
|
858
|
+
#
|
859
|
+
# ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
|
860
|
+
# p ec.convert("\u3042") #=> "\e$B$\""
|
861
|
+
# p ec.finish #=> "\e(B"
|
862
|
+
#
|
863
|
+
def finish: () -> String
|
864
|
+
|
865
|
+
# <!--
|
866
|
+
# rdoc-file=transcode.c
|
867
|
+
# - ec.insert_output(string) -> nil
|
868
|
+
# -->
|
869
|
+
# Inserts string into the encoding converter. The string will be converted to
|
870
|
+
# the destination encoding and output on later conversions.
|
871
|
+
#
|
872
|
+
# If the destination encoding is stateful, string is converted according to the
|
873
|
+
# state and the state is updated.
|
874
|
+
#
|
875
|
+
# This method should be used only when a conversion error occurs.
|
876
|
+
#
|
877
|
+
# ec = Encoding::Converter.new("utf-8", "iso-8859-1")
|
878
|
+
# src = "HIRAGANA LETTER A is \u{3042}."
|
879
|
+
# dst = ""
|
880
|
+
# p ec.primitive_convert(src, dst) #=> :undefined_conversion
|
881
|
+
# puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is ", "."]
|
882
|
+
# ec.insert_output("<err>")
|
883
|
+
# p ec.primitive_convert(src, dst) #=> :finished
|
884
|
+
# puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is <err>.", ""]
|
885
|
+
#
|
886
|
+
# ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
|
887
|
+
# src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp
|
888
|
+
# dst = ""
|
889
|
+
# p ec.primitive_convert(src, dst) #=> :undefined_conversion
|
890
|
+
# puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP"), "\xE3\x80\x82"]
|
891
|
+
# ec.insert_output "?" # state change required to output "?".
|
892
|
+
# p ec.primitive_convert(src, dst) #=> :finished
|
893
|
+
# puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H\e(B?\e$B!#\e(B".force_encoding("ISO-2022-JP"), ""]
|
894
|
+
#
|
895
|
+
def insert_output: (String) -> nil
|
896
|
+
|
897
|
+
# <!--
|
898
|
+
# rdoc-file=transcode.c
|
899
|
+
# - ec.inspect -> string
|
900
|
+
# -->
|
901
|
+
# Returns a printable version of *ec*
|
902
|
+
#
|
903
|
+
# ec = Encoding::Converter.new("iso-8859-1", "utf-8")
|
904
|
+
# puts ec.inspect #=> #<Encoding::Converter: ISO-8859-1 to UTF-8>
|
905
|
+
#
|
906
|
+
def inspect: () -> String
|
907
|
+
|
908
|
+
# <!--
|
909
|
+
# rdoc-file=transcode.c
|
910
|
+
# - ec.last_error -> exception or nil
|
911
|
+
# -->
|
912
|
+
# Returns an exception object for the last conversion. Returns nil if the last
|
913
|
+
# conversion did not produce an error.
|
914
|
+
#
|
915
|
+
# "error" means that Encoding::InvalidByteSequenceError and
|
916
|
+
# Encoding::UndefinedConversionError for Encoding::Converter#convert and
|
917
|
+
# :invalid_byte_sequence, :incomplete_input and :undefined_conversion for
|
918
|
+
# Encoding::Converter#primitive_convert.
|
919
|
+
#
|
920
|
+
# ec = Encoding::Converter.new("utf-8", "iso-8859-1")
|
921
|
+
# p ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence
|
922
|
+
# p ec.last_error #=> #<Encoding::InvalidByteSequenceError: "\xF1" followed by "a" on UTF-8>
|
923
|
+
# p ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full
|
924
|
+
# p ec.last_error #=> nil
|
925
|
+
#
|
926
|
+
def last_error: () -> Encoding::InvalidByteSequenceError?
|
927
|
+
| () -> Encoding::UndefinedConversionError?
|
928
|
+
|
929
|
+
# <!--
|
930
|
+
# rdoc-file=transcode.c
|
931
|
+
# - ec.primitive_convert(source_buffer, destination_buffer) -> symbol
|
932
|
+
# - ec.primitive_convert(source_buffer, destination_buffer, destination_byteoffset) -> symbol
|
933
|
+
# - ec.primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) -> symbol
|
934
|
+
# - ec.primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, opt) -> symbol
|
935
|
+
# -->
|
936
|
+
# possible opt elements:
|
937
|
+
# hash form:
|
938
|
+
# :partial_input => true # source buffer may be part of larger source
|
939
|
+
# :after_output => true # stop conversion after output before input
|
940
|
+
# integer form:
|
941
|
+
# Encoding::Converter::PARTIAL_INPUT
|
942
|
+
# Encoding::Converter::AFTER_OUTPUT
|
943
|
+
#
|
944
|
+
# possible results:
|
945
|
+
# :invalid_byte_sequence
|
946
|
+
# :incomplete_input
|
947
|
+
# :undefined_conversion
|
948
|
+
# :after_output
|
949
|
+
# :destination_buffer_full
|
950
|
+
# :source_buffer_empty
|
951
|
+
# :finished
|
952
|
+
#
|
953
|
+
# primitive_convert converts source_buffer into destination_buffer.
|
954
|
+
#
|
955
|
+
# source_buffer should be a string or nil. nil means an empty string.
|
956
|
+
#
|
957
|
+
# destination_buffer should be a string.
|
958
|
+
#
|
959
|
+
# destination_byteoffset should be an integer or nil. nil means the end of
|
960
|
+
# destination_buffer. If it is omitted, nil is assumed.
|
961
|
+
#
|
962
|
+
# destination_bytesize should be an integer or nil. nil means unlimited. If it
|
963
|
+
# is omitted, nil is assumed.
|
964
|
+
#
|
965
|
+
# opt should be nil, a hash or an integer. nil means no flags. If it is omitted,
|
966
|
+
# nil is assumed.
|
967
|
+
#
|
968
|
+
# primitive_convert converts the content of source_buffer from beginning and
|
969
|
+
# store the result into destination_buffer.
|
970
|
+
#
|
971
|
+
# destination_byteoffset and destination_bytesize specify the region which the
|
972
|
+
# converted result is stored. destination_byteoffset specifies the start
|
973
|
+
# position in destination_buffer in bytes. If destination_byteoffset is nil,
|
974
|
+
# destination_buffer.bytesize is used for appending the result.
|
975
|
+
# destination_bytesize specifies maximum number of bytes. If
|
976
|
+
# destination_bytesize is nil, destination size is unlimited. After conversion,
|
977
|
+
# destination_buffer is resized to destination_byteoffset + actually produced
|
978
|
+
# number of bytes. Also destination_buffer's encoding is set to
|
979
|
+
# destination_encoding.
|
980
|
+
#
|
981
|
+
# primitive_convert drops the converted part of source_buffer. the dropped part
|
982
|
+
# is converted in destination_buffer or buffered in Encoding::Converter object.
|
983
|
+
#
|
984
|
+
# primitive_convert stops conversion when one of following condition met.
|
985
|
+
# * invalid byte sequence found in source buffer (:invalid_byte_sequence)
|
986
|
+
# `primitive_errinfo` and `last_error` methods returns the detail of the
|
987
|
+
# error.
|
988
|
+
# * unexpected end of source buffer (:incomplete_input) this occur only when
|
989
|
+
# :partial_input is not specified. `primitive_errinfo` and `last_error`
|
990
|
+
# methods returns the detail of the error.
|
991
|
+
# * character not representable in output encoding (:undefined_conversion)
|
992
|
+
# `primitive_errinfo` and `last_error` methods returns the detail of the
|
993
|
+
# error.
|
994
|
+
# * after some output is generated, before input is done (:after_output) this
|
995
|
+
# occur only when :after_output is specified.
|
996
|
+
# * destination buffer is full (:destination_buffer_full) this occur only when
|
997
|
+
# destination_bytesize is non-nil.
|
998
|
+
# * source buffer is empty (:source_buffer_empty) this occur only when
|
999
|
+
# :partial_input is specified.
|
1000
|
+
# * conversion is finished (:finished)
|
1001
|
+
#
|
1002
|
+
# example:
|
1003
|
+
# ec = Encoding::Converter.new("UTF-8", "UTF-16BE")
|
1004
|
+
# ret = ec.primitive_convert(src="pi", dst="", nil, 100)
|
1005
|
+
# p [ret, src, dst] #=> [:finished, "", "\x00p\x00i"]
|
1006
|
+
#
|
1007
|
+
# ec = Encoding::Converter.new("UTF-8", "UTF-16BE")
|
1008
|
+
# ret = ec.primitive_convert(src="pi", dst="", nil, 1)
|
1009
|
+
# p [ret, src, dst] #=> [:destination_buffer_full, "i", "\x00"]
|
1010
|
+
# ret = ec.primitive_convert(src, dst="", nil, 1)
|
1011
|
+
# p [ret, src, dst] #=> [:destination_buffer_full, "", "p"]
|
1012
|
+
# ret = ec.primitive_convert(src, dst="", nil, 1)
|
1013
|
+
# p [ret, src, dst] #=> [:destination_buffer_full, "", "\x00"]
|
1014
|
+
# ret = ec.primitive_convert(src, dst="", nil, 1)
|
1015
|
+
# p [ret, src, dst] #=> [:finished, "", "i"]
|
1016
|
+
#
|
1017
|
+
def primitive_convert: (
|
1018
|
+
String? source,
|
1019
|
+
String destination,
|
1020
|
+
?Integer? destination_byteoffset,
|
1021
|
+
?Integer? destination_bytesize,
|
1022
|
+
?partial_input: bool,
|
1023
|
+
?after_output: bool
|
1024
|
+
) -> convert_result
|
1025
|
+
| (
|
1026
|
+
String? source,
|
1027
|
+
String destination,
|
1028
|
+
?Integer? destination_byteoffset,
|
1029
|
+
?Integer? destination_bytesize,
|
1030
|
+
?Integer opt
|
1031
|
+
) -> convert_result
|
1032
|
+
|
1033
|
+
# <!--
|
1034
|
+
# rdoc-file=transcode.c
|
1035
|
+
# - ec.primitive_errinfo -> array
|
1036
|
+
# -->
|
1037
|
+
# primitive_errinfo returns important information regarding the last error as a
|
1038
|
+
# 5-element array:
|
1039
|
+
#
|
1040
|
+
# [result, enc1, enc2, error_bytes, readagain_bytes]
|
1041
|
+
#
|
1042
|
+
# result is the last result of primitive_convert.
|
1043
|
+
#
|
1044
|
+
# Other elements are only meaningful when result is :invalid_byte_sequence,
|
1045
|
+
# :incomplete_input or :undefined_conversion.
|
1046
|
+
#
|
1047
|
+
# enc1 and enc2 indicate a conversion step as a pair of strings. For example, a
|
1048
|
+
# converter from EUC-JP to ISO-8859-1 converts a string as follows: EUC-JP ->
|
1049
|
+
# UTF-8 -> ISO-8859-1. So [enc1, enc2] is either ["EUC-JP", "UTF-8"] or
|
1050
|
+
# ["UTF-8", "ISO-8859-1"].
|
1051
|
+
#
|
1052
|
+
# error_bytes and readagain_bytes indicate the byte sequences which caused the
|
1053
|
+
# error. error_bytes is discarded portion. readagain_bytes is buffered portion
|
1054
|
+
# which is read again on next conversion.
|
1055
|
+
#
|
1056
|
+
# Example:
|
1057
|
+
#
|
1058
|
+
# # \xff is invalid as EUC-JP.
|
1059
|
+
# ec = Encoding::Converter.new("EUC-JP", "Shift_JIS")
|
1060
|
+
# ec.primitive_convert(src="\xff", dst="", nil, 10)
|
1061
|
+
# p ec.primitive_errinfo
|
1062
|
+
# #=> [:invalid_byte_sequence, "EUC-JP", "Shift_JIS", "\xFF", ""]
|
1063
|
+
#
|
1064
|
+
# # HIRAGANA LETTER A (\xa4\xa2 in EUC-JP) is not representable in ISO-8859-1.
|
1065
|
+
# # Since this error is occur in UTF-8 to ISO-8859-1 conversion,
|
1066
|
+
# # error_bytes is HIRAGANA LETTER A in UTF-8 (\xE3\x81\x82).
|
1067
|
+
# ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
1068
|
+
# ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10)
|
1069
|
+
# p ec.primitive_errinfo
|
1070
|
+
# #=> [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", ""]
|
1071
|
+
#
|
1072
|
+
# # partial character is invalid
|
1073
|
+
# ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
1074
|
+
# ec.primitive_convert(src="\xa4", dst="", nil, 10)
|
1075
|
+
# p ec.primitive_errinfo
|
1076
|
+
# #=> [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""]
|
1077
|
+
#
|
1078
|
+
# # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by
|
1079
|
+
# # partial characters.
|
1080
|
+
# ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
1081
|
+
# ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT)
|
1082
|
+
# p ec.primitive_errinfo
|
1083
|
+
# #=> [:source_buffer_empty, nil, nil, nil, nil]
|
1084
|
+
#
|
1085
|
+
# # \xd8\x00\x00@ is invalid as UTF-16BE because
|
1086
|
+
# # no low surrogate after high surrogate (\xd8\x00).
|
1087
|
+
# # It is detected by 3rd byte (\00) which is part of next character.
|
1088
|
+
# # So the high surrogate (\xd8\x00) is discarded and
|
1089
|
+
# # the 3rd byte is read again later.
|
1090
|
+
# # Since the byte is buffered in ec, it is dropped from src.
|
1091
|
+
# ec = Encoding::Converter.new("UTF-16BE", "UTF-8")
|
1092
|
+
# ec.primitive_convert(src="\xd8\x00\x00@", dst="", nil, 10)
|
1093
|
+
# p ec.primitive_errinfo
|
1094
|
+
# #=> [:invalid_byte_sequence, "UTF-16BE", "UTF-8", "\xD8\x00", "\x00"]
|
1095
|
+
# p src
|
1096
|
+
# #=> "@"
|
1097
|
+
#
|
1098
|
+
# # Similar to UTF-16BE, \x00\xd8@\x00 is invalid as UTF-16LE.
|
1099
|
+
# # The problem is detected by 4th byte.
|
1100
|
+
# ec = Encoding::Converter.new("UTF-16LE", "UTF-8")
|
1101
|
+
# ec.primitive_convert(src="\x00\xd8@\x00", dst="", nil, 10)
|
1102
|
+
# p ec.primitive_errinfo
|
1103
|
+
# #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "@\x00"]
|
1104
|
+
# p src
|
1105
|
+
# #=> ""
|
1106
|
+
#
|
1107
|
+
def primitive_errinfo: () -> [convert_result, String?, String?, String?, String?]
|
1108
|
+
|
1109
|
+
# <!--
|
1110
|
+
# rdoc-file=transcode.c
|
1111
|
+
# - ec.putback -> string
|
1112
|
+
# - ec.putback(max_numbytes) -> string
|
1113
|
+
# -->
|
1114
|
+
# Put back the bytes which will be converted.
|
1115
|
+
#
|
1116
|
+
# The bytes are caused by invalid_byte_sequence error. When
|
1117
|
+
# invalid_byte_sequence error, some bytes are discarded and some bytes are
|
1118
|
+
# buffered to be converted later. The latter bytes can be put back. It can be
|
1119
|
+
# observed by Encoding::InvalidByteSequenceError#readagain_bytes and
|
1120
|
+
# Encoding::Converter#primitive_errinfo.
|
1121
|
+
#
|
1122
|
+
# ec = Encoding::Converter.new("utf-16le", "iso-8859-1")
|
1123
|
+
# src = "\x00\xd8\x61\x00"
|
1124
|
+
# dst = ""
|
1125
|
+
# p ec.primitive_convert(src, dst) #=> :invalid_byte_sequence
|
1126
|
+
# p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"]
|
1127
|
+
# p ec.putback #=> "a\x00"
|
1128
|
+
# p ec.putback #=> "" # no more bytes to put back
|
1129
|
+
#
|
1130
|
+
def putback: (?Integer max_numbytes) -> String
|
1131
|
+
|
1132
|
+
# <!--
|
1133
|
+
# rdoc-file=transcode.c
|
1134
|
+
# - ec.replacement -> string
|
1135
|
+
# -->
|
1136
|
+
# Returns the replacement string.
|
1137
|
+
#
|
1138
|
+
# ec = Encoding::Converter.new("euc-jp", "us-ascii")
|
1139
|
+
# p ec.replacement #=> "?"
|
1140
|
+
#
|
1141
|
+
# ec = Encoding::Converter.new("euc-jp", "utf-8")
|
1142
|
+
# p ec.replacement #=> "\uFFFD"
|
1143
|
+
#
|
1144
|
+
def replacement: () -> String
|
1145
|
+
|
1146
|
+
# <!--
|
1147
|
+
# rdoc-file=transcode.c
|
1148
|
+
# - ec.replacement = string
|
1149
|
+
# -->
|
1150
|
+
# Sets the replacement string.
|
1151
|
+
#
|
1152
|
+
# ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace)
|
1153
|
+
# ec.replacement = "<undef>"
|
1154
|
+
# p ec.convert("a \u3042 b") #=> "a <undef> b"
|
1155
|
+
#
|
1156
|
+
def replacement=: (String str) -> String
|
1157
|
+
|
1158
|
+
# <!--
|
1159
|
+
# rdoc-file=transcode.c
|
1160
|
+
# - ec.source_encoding -> encoding
|
1161
|
+
# -->
|
1162
|
+
# Returns the source encoding as an Encoding object.
|
1163
|
+
#
|
1164
|
+
def source_encoding: () -> Encoding
|
1165
|
+
|
1166
|
+
private
|
1167
|
+
|
1168
|
+
# <!--
|
1169
|
+
# rdoc-file=transcode.c
|
1170
|
+
# - Encoding::Converter.new(source_encoding, destination_encoding)
|
1171
|
+
# - Encoding::Converter.new(source_encoding, destination_encoding, opt)
|
1172
|
+
# - Encoding::Converter.new(convpath)
|
1173
|
+
# -->
|
1174
|
+
# possible options elements:
|
1175
|
+
# hash form:
|
1176
|
+
# :invalid => nil # raise error on invalid byte sequence (default)
|
1177
|
+
# :invalid => :replace # replace invalid byte sequence
|
1178
|
+
# :undef => nil # raise error on undefined conversion (default)
|
1179
|
+
# :undef => :replace # replace undefined conversion
|
1180
|
+
# :replace => string # replacement string ("?" or "\uFFFD" if not specified)
|
1181
|
+
# :newline => :universal # decorator for converting CRLF and CR to LF
|
1182
|
+
# :newline => :lf # decorator for converting CRLF and CR to LF when writing
|
1183
|
+
# :newline => :crlf # decorator for converting LF to CRLF
|
1184
|
+
# :newline => :cr # decorator for converting LF to CR
|
1185
|
+
# :universal_newline => true # decorator for converting CRLF and CR to LF
|
1186
|
+
# :crlf_newline => true # decorator for converting LF to CRLF
|
1187
|
+
# :cr_newline => true # decorator for converting LF to CR
|
1188
|
+
# :lf_newline => true # decorator for converting CRLF and CR to LF when writing
|
1189
|
+
# :xml => :text # escape as XML CharData.
|
1190
|
+
# :xml => :attr # escape as XML AttValue
|
1191
|
+
# integer form:
|
1192
|
+
# Encoding::Converter::INVALID_REPLACE
|
1193
|
+
# Encoding::Converter::UNDEF_REPLACE
|
1194
|
+
# Encoding::Converter::UNDEF_HEX_CHARREF
|
1195
|
+
# Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR
|
1196
|
+
# Encoding::Converter::LF_NEWLINE_DECORATOR
|
1197
|
+
# Encoding::Converter::CRLF_NEWLINE_DECORATOR
|
1198
|
+
# Encoding::Converter::CR_NEWLINE_DECORATOR
|
1199
|
+
# Encoding::Converter::XML_TEXT_DECORATOR
|
1200
|
+
# Encoding::Converter::XML_ATTR_CONTENT_DECORATOR
|
1201
|
+
# Encoding::Converter::XML_ATTR_QUOTE_DECORATOR
|
1202
|
+
#
|
1203
|
+
# Encoding::Converter.new creates an instance of Encoding::Converter.
|
1204
|
+
#
|
1205
|
+
# Source_encoding and destination_encoding should be a string or Encoding
|
1206
|
+
# object.
|
1207
|
+
#
|
1208
|
+
# opt should be nil, a hash or an integer.
|
1209
|
+
#
|
1210
|
+
# convpath should be an array. convpath may contain
|
1211
|
+
# * two-element arrays which contain encodings or encoding names, or
|
1212
|
+
# * strings representing decorator names.
|
1213
|
+
#
|
1214
|
+
# Encoding::Converter.new optionally takes an option. The option should be a
|
1215
|
+
# hash or an integer. The option hash can contain :invalid => nil, etc. The
|
1216
|
+
# option integer should be logical-or of constants such as
|
1217
|
+
# Encoding::Converter::INVALID_REPLACE, etc.
|
1218
|
+
#
|
1219
|
+
# :invalid => nil
|
1220
|
+
# : Raise error on invalid byte sequence. This is a default behavior.
|
1221
|
+
#
|
1222
|
+
# :invalid => :replace
|
1223
|
+
# : Replace invalid byte sequence by replacement string.
|
1224
|
+
#
|
1225
|
+
# :undef => nil
|
1226
|
+
# : Raise an error if a character in source_encoding is not defined in
|
1227
|
+
# destination_encoding. This is a default behavior.
|
1228
|
+
#
|
1229
|
+
# :undef => :replace
|
1230
|
+
# : Replace undefined character in destination_encoding with replacement
|
1231
|
+
# string.
|
1232
|
+
#
|
1233
|
+
# :replace => string
|
1234
|
+
# : Specify the replacement string. If not specified, "uFFFD" is used for
|
1235
|
+
# Unicode encodings and "?" for others.
|
1236
|
+
#
|
1237
|
+
# :universal_newline => true
|
1238
|
+
# : Convert CRLF and CR to LF.
|
1239
|
+
#
|
1240
|
+
# :crlf_newline => true
|
1241
|
+
# : Convert LF to CRLF.
|
1242
|
+
#
|
1243
|
+
# :cr_newline => true
|
1244
|
+
# : Convert LF to CR.
|
1245
|
+
#
|
1246
|
+
# :lf_newline => true
|
1247
|
+
# : Convert CRLF and CR to LF (when writing).
|
1248
|
+
#
|
1249
|
+
# :xml => :text
|
1250
|
+
# : Escape as XML CharData. This form can be used as an HTML 4.0 #PCDATA.
|
1251
|
+
# * '&' -> '&'
|
1252
|
+
# * '<' -> '<'
|
1253
|
+
# * '>' -> '>'
|
1254
|
+
# * undefined characters in destination_encoding -> hexadecimal CharRef
|
1255
|
+
# such as &#xHH;
|
1256
|
+
#
|
1257
|
+
# :xml => :attr
|
1258
|
+
# : Escape as XML AttValue. The converted result is quoted as "...". This form
|
1259
|
+
# can be used as an HTML 4.0 attribute value.
|
1260
|
+
# * '&' -> '&'
|
1261
|
+
# * '<' -> '<'
|
1262
|
+
# * '>' -> '>'
|
1263
|
+
# * '"' -> '"'
|
1264
|
+
# * undefined characters in destination_encoding -> hexadecimal CharRef
|
1265
|
+
# such as &#xHH;
|
1266
|
+
#
|
1267
|
+
#
|
1268
|
+
# Examples:
|
1269
|
+
# # UTF-16BE to UTF-8
|
1270
|
+
# ec = Encoding::Converter.new("UTF-16BE", "UTF-8")
|
1271
|
+
#
|
1272
|
+
# # Usually, decorators such as newline conversion are inserted last.
|
1273
|
+
# ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true)
|
1274
|
+
# p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
|
1275
|
+
# # "universal_newline"]
|
1276
|
+
#
|
1277
|
+
# # But, if the last encoding is ASCII incompatible,
|
1278
|
+
# # decorators are inserted before the last conversion.
|
1279
|
+
# ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
|
1280
|
+
# p ec.convpath #=> ["crlf_newline",
|
1281
|
+
# # [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
|
1282
|
+
#
|
1283
|
+
# # Conversion path can be specified directly.
|
1284
|
+
# ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UTF-8", "UTF-16BE"]])
|
1285
|
+
# p ec.convpath #=> ["universal_newline",
|
1286
|
+
# # [#<Encoding:EUC-JP>, #<Encoding:UTF-8>],
|
1287
|
+
# # [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
|
1288
|
+
#
|
1289
|
+
def initialize: (encoding source, encoding destination) -> void
|
1290
|
+
| (encoding source, encoding destination,
|
1291
|
+
?invalid: :replace | nil,
|
1292
|
+
?undef: :replace | nil,
|
1293
|
+
?replace: String,
|
1294
|
+
?newline: :universal | :crlf | :cr,
|
1295
|
+
?universal_newline: bool,
|
1296
|
+
?crlf_newline: bool,
|
1297
|
+
?cr_newline: bool,
|
1298
|
+
?xml: :text | :attr
|
1299
|
+
) -> void
|
1300
|
+
| (encoding source, encoding destination, Integer opts) -> void
|
1301
|
+
| (conversion_path convpath) -> void
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
# <!-- rdoc-file=transcode.c -->
|
1305
|
+
# Stop converting after some output is complete but before all of the input was
|
1306
|
+
# consumed. See primitive_convert for an example.
|
1307
|
+
#
|
1308
|
+
Encoding::Converter::AFTER_OUTPUT: Integer
|
1309
|
+
|
1310
|
+
# <!-- rdoc-file=transcode.c -->
|
1311
|
+
# Decorator for converting LF to CRLF
|
1312
|
+
#
|
1313
|
+
Encoding::Converter::CRLF_NEWLINE_DECORATOR: Integer
|
1314
|
+
|
1315
|
+
# <!-- rdoc-file=transcode.c -->
|
1316
|
+
# Decorator for converting LF to CR
|
1317
|
+
#
|
1318
|
+
Encoding::Converter::CR_NEWLINE_DECORATOR: Integer
|
1319
|
+
|
1320
|
+
# <!-- rdoc-file=transcode.c -->
|
1321
|
+
# Mask for invalid byte sequences
|
1322
|
+
#
|
1323
|
+
Encoding::Converter::INVALID_MASK: Integer
|
1324
|
+
|
1325
|
+
# <!-- rdoc-file=transcode.c -->
|
1326
|
+
# Replace invalid byte sequences
|
1327
|
+
#
|
1328
|
+
Encoding::Converter::INVALID_REPLACE: Integer
|
1329
|
+
|
1330
|
+
# <!-- rdoc-file=transcode.c -->
|
1331
|
+
# Indicates the source may be part of a larger string. See primitive_convert
|
1332
|
+
# for an example.
|
1333
|
+
#
|
1334
|
+
Encoding::Converter::PARTIAL_INPUT: Integer
|
1335
|
+
|
1336
|
+
# <!-- rdoc-file=transcode.c -->
|
1337
|
+
# Replace byte sequences that are undefined in the destination encoding with an
|
1338
|
+
# XML hexadecimal character reference. This is valid for XML conversion.
|
1339
|
+
#
|
1340
|
+
Encoding::Converter::UNDEF_HEX_CHARREF: Integer
|
1341
|
+
|
1342
|
+
# <!-- rdoc-file=transcode.c -->
|
1343
|
+
# Mask for a valid character in the source encoding but no related character(s)
|
1344
|
+
# in destination encoding.
|
1345
|
+
#
|
1346
|
+
Encoding::Converter::UNDEF_MASK: Integer
|
1347
|
+
|
1348
|
+
# <!-- rdoc-file=transcode.c -->
|
1349
|
+
# Replace byte sequences that are undefined in the destination encoding.
|
1350
|
+
#
|
1351
|
+
Encoding::Converter::UNDEF_REPLACE: Integer
|
1352
|
+
|
1353
|
+
# <!-- rdoc-file=transcode.c -->
|
1354
|
+
# Decorator for converting CRLF and CR to LF
|
1355
|
+
#
|
1356
|
+
Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR: Integer
|
1357
|
+
|
1358
|
+
# <!-- rdoc-file=transcode.c -->
|
1359
|
+
# Escape as XML AttValue
|
1360
|
+
#
|
1361
|
+
Encoding::Converter::XML_ATTR_CONTENT_DECORATOR: Integer
|
1362
|
+
|
1363
|
+
# <!-- rdoc-file=transcode.c -->
|
1364
|
+
# Escape as XML AttValue
|
1365
|
+
#
|
1366
|
+
Encoding::Converter::XML_ATTR_QUOTE_DECORATOR: Integer
|
1367
|
+
|
1368
|
+
# <!-- rdoc-file=transcode.c -->
|
1369
|
+
# Escape as XML CharData
|
1370
|
+
#
|
1371
|
+
Encoding::Converter::XML_TEXT_DECORATOR: Integer
|