Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NKF constants #338

kachick opened this issue Oct 8, 2012 · 4 comments

NKF constants #338

kachick opened this issue Oct 8, 2012 · 4 comments


Copy link

kachick commented Oct 8, 2012

I noticed the following behavior when using NKF.guess.


require 'nkf'

NKF.constants(true).sort.each do |cons|
  puts "#{cons} => #{NKF.const_get(cons).inspect}"


ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

ASCII => #<Encoding:US-ASCII>
AUTO => nil
BINARY => #<Encoding:ASCII-8BIT>
EUC => #<Encoding:EUC-JP>
JIS => #<Encoding:ISO-2022-JP (dummy)>
NKF_RELEASE_DATE => "2011-09-08"
NKF_VERSION => "2.1.2"
NOCONV => nil
SJIS => #<Encoding:Shift_JIS>
UNKNOWN => nil
UTF16 => #<Encoding:UTF-16BE>
UTF32 => #<Encoding:UTF-32BE>
UTF8 => #<Encoding:UTF-8>
VERSION => "2.1.2 (2011-09-08)"

jruby 1.7.0.RC1 (1.9.3p203) 2012-10-09 689e08f on OpenJDK 64-Bit Server VM 1.6.0_24-b24 [linux-amd64]

ASCII => 5
AUTO => 0
BASE64 => 20
EUC => 2
JIS => 1
OTHER => 16
SJIS => 3
UTF16 => 8
UTF32 => 12
UTF8 => 6
jrubyci pushed a commit that referenced this issue Mar 4, 2013
…irectories ending in slash

* Ruboto Issue #338 Using  and __FILE__
Copy link

I checked this on master since it's such an old bug and it's still there. I don't know anything about NKF so can't comment on it being a meaningful bug though.

Copy link

headius commented Jun 3, 2015

Looks like at some point these changed to be Encoding, rather than numeric values...probably 1.9/M17N timeframe.

Copy link
Contributor Author

kachick commented Nov 15, 2015

Thanks you! 🙇

kares added a commit that referenced this issue Nov 15, 2015
* jruby-1_7: (46 commits)
  make previous commit null-safe + review JRuby home verification - normalize once!
  normalize JRubyHome for windows.
  backport ruby 1.9.3 test_bigdecimal from MRI (NAN.round no longer supposed to fail)
  make sure BigDecimal test restores exception modes + make nan asserts 1.8 compat
  handle BigDecimal#round-ing for NaN (does not raise since 1.8.7 current MRI 2.2.3)
  update to latest jruby-openssl release: 0.9.12
  update options library to latest 1.3 release
  re-format code - mislined line + unused variable & use indexOf(char) instead of str
  avoid expensive pattern compiling in arg processing loop (split() and replaceAll())
  [nkf] handle 1.9.3 NKF library compatibility - returning encoding objects (see #338)
  avoid double convertToInteger and double NKF map lookup in EncodingService
  define NKF version constants (based on MRI 1.8.7 ... which is how NKF is compatible)
  make NKF shared public static map final
  correct ArgumentError message format to match MRI >= 1.9.3 (fixes #3346)
  be failsafe when trying to load META-INF/maven/org.yaml/snakeyaml/
  fix generics (for master backport) to dispatch to correct CallableSelector override
  move CallableCache internal interface were it fits + add matching methods for arities
  invent a "true" null (java) callable cache for invokers + make get/put signature final
  refactor (internal) Java.__jcreate! impl to use same cache as RubyToJavaInvoker-s ... introducing an internal CallableCache interface to loose coupling in CallableSelector
  Use Cliff Click's high-scale collections instead of IntHashMap.

Copy link

It now returns proper constants but returned values differ from what MRI returns. An empty string returns nil while MRI returns Encoding:ASCII-8BIT

eregon added a commit that referenced this issue Oct 29, 2016
a2e5952 Specs for Complex explicitly removing positive? and negative?.
d0c8343 Add spec for backtrace from rescue that only captures $!.
197292f Specs for conditionally-assigned variables accessed in closure.
ad581ab Fix Hash#assoc spec to avoid a CRuby >= 2.2 bug
fe9e1d1 Add spec for Range#include? with Time endpoints.
a0a7642 add more spec for ||= and &&=
f06c18d Spec for passing a block to forms of [] method.
e20cc56 Add spec for EAFNOSUPPORT in udp sockets
767d983 Add specs
53466eb Add specs for * and ** coercion of BasicObject types.
f3e2edf Fix typo in socketpair_spec.rb.
a0780cd Fix Socket#socketpair shared spec
048320b Add Socket#socketpair response type spec
5ee05bc This only appears to work on OS X.
1278eb2 Spec for IO#seek > 2^32.
e81f3e5 Fix extra space
a5f6f5e Specs for rb_obj_method_arity.
e990a71 Fix WIN32OLE_METHOD#offset_vtbl spec for 64-bit Windows
aa3697e Split platform-dependent parts in Float#round specs
9d0932f Handle the special case of x64-mingw32 for String#unpack('J') specs
849e1e2 Handle the special case of x64-mingw32 for Array#pack('J') specs
9689d97 Try running on 64-bit Ruby 2.3 on Windows
3a71993 Merge pull request #346 from mjago/fix_encodings
31c3d16 Fix encoding in core/string/shared/codepoints.rb
5191351 Fix encoding in core/string/shared/chars.rb
5213d36 Fix encoding in core/string/scrub_spec.rb
3f70703 Fix encoding in core/string/new_spec.rb
ac1e312 Exclude connect_nonblock raises Errno::EINPROGRESS
25a1538 Merge pull request #344 from mjago/socket_option_on_aix
ba36b85 Merge pull request #345 from mjago/fix_encoding
16b6441 Fix encoding in core/string/gsub_spec.rb
a083778 Fix encoding in core/string/getbyte_spec.rb
769d842 Fix encoding in core/string/fixtures/iso-8859-9-encoding.rb
d5141d5 Fix encoding in core/string/encoding_spec.rb
68d48e7 Fix encoding in core/string/encoding_spec.rb
608140c Fix encoding in core/string/element_set_spec.rb
96ebe46 Avoid use of getsockopt for setsockopt specs on aix
42cfee7 Merge pull request #343 from mjago/fix_encodings
ef14dee Fix encoding in core/string/delete_spec.rb
0325dfb Fix encoding in core/string/count_spec.rb
fc80507 Fix encoding in core/string/comparison_spec.rb
0f1590f Fix encoding in core/regexp/shared/new_ascii.rb
e30e3ab Remove extraneous parenthesis
7ecb1aa Merge pull request #342 from mjago/encoding_fixes
3e60d4c Add back `larger than UTF-8 max codepoints' spec
2c1dd28 Really fix encoding in unicode.rb
b752874 Fix encoding in core/array/pack/shared/unicode.rb
0317231 Merge pull request #341 from mjago/aix_socket_constants
17b07cf Fix encoding in core/array/pack/shared/string.rb
87d371b Fix encoding in core/array/fixtures/encoded_strings.rb
3702273 Fix whitespace
7c0d354 Remove IP_MAX_MEMBERSHIPS check on AIX platform
fa2ec3d Don't check for IPX socket constants on AIX platform
3ea90df Merge pull request #340 from iliabylich/add-more-specs-for-squiggly-heredoc
8fbd1ad More specs for "squiggly" heredoc.
b3b68c7 Merge pull request #339 from mjago/fix_stringscanner_encodings
b21cea4 Fix encoding in stringscanner/shared/get_byte.rb
2964778 Fix encoding in stringscanner/getch_spec.rb
05dbe0e Merge pull request #338 from mjago/fix_unbranch_on_big_endian
201a176 Fix unpack specs with j option on big-endian systems
5605faf Merge pull request #337 from mjago/fix_encodings
c601f85 Fix encodings in core/encoding/replicate_spec.rb
eb1d56d Fix encoding in encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb
26ee43a Accept both possible values for Socket::Option#linger
ff41556 Do not make assumptions on the value of Dir#pos
b4bfa56 Merge pull request #336 from mjago/fix_j_spec_for_big_endian_platforms
864e2e1 Fix specs for Array pack with format J and j specs
151f7c6 Merge pull request #331 from mjago/unpack_option_j_specs
4c8b9b3 Fix encoding/invalid_byte_sequence_error/incomplete_input_spec.rb
626fab3 Fix encoding in encoding/invalid_byte_sequence_error/error_bytes_spec.rb
db30005 Fix encoding in encoding/fixtures/classes.rb
f4b5e0d Fix encoding in encoding/converter/putback_spec.rb
7e99711 Add specs for unpack options J and j
bcb318b Move require to example so unsupported syntax would only fail that example
57c69fc tests squiggly heredoc * See #175 * See [Feature 9098]
ce4eb8f Fix encoding in encoding/converter/primitive_errinfo_spec.rb
ef64e76 Fix encoding in encoding/converter/primitive_convert_spec.rb
8466a28 Fix encoding in encoding/converter/last_error_spec.rb
e0d32ca Fix encoding in encoding/converter/convert_spec.rb
a743e63 Fix encoding in core/string/codepoints_spec.rb
6353bbe Fix encoding in core/string/byteslice_spec.rb
5d1f1cb Revert "Travis: allow ruby-head to fail since it's outdated"
5ec5a10 Array pack with format J and j specs (#320)
6068505 Merge pull request #321 from mjago/fix_encoding_in_recv_spec
fb52aef Fix encoding in recv_spec.rb
96f8e44 Merge pull request #319 from mjago/fix_match_spec_utf8
012827a Fix utf-8 conflicts in Regexp match specs
f3c10d3 Fix magic encoding to avoid utf-8 conflicts
adfb2eb Merge pull request #316 from mjago/avoid_utf8_conflicts_in_io_specs
c6daa63 Fix alignment
044b889 Rename data to write
d259a19 Remove redundant artifact
3a71973 Avoid utf-8 conflicts in IO specs
402b2cb Fix expectation in a zlib spec
bee369d Zlib specs should use binary strings
c77a0e9 Merge pull request #315 from sgarciac/master
1334490 Tests Base64#urlsafe_encode64 and Base64#urlsafe_decode64 * See #175 * See [Feature 10740]
80937d6 Merge pull request #313 from mjago/avoid_utf8_conflicts_with_binary_encoding_in_marshall_specs
6e2efe7 Merge pull request #314 from mjago/fix_utf8_conflict_in_expand_path_spec
4df37ac DRY spec
d96bde0 Fix tests
6d47911 Fix utf-8 conflict in expand_path_spec.rb
7d1e89a Avoid utf8 conflicts in Marshall specs
45f9256 Merge pull request #312 from mjago/avoid_utf8_conflicts_with_binary_encoding_in_digest_specs
1884a0e Avoid utf-8 conflicts in Digest files
c4cabcf Add specs for yielding to a lambda with an Array and the wrong number of arguments
de4fab0 Remove extra encoding comment
c65e5ca Merge pull request #311 from mjago/avoid_problematic_encodings_in_zlib_specs
7b91144 Avoid problematic encodings in Zlib specs
a0a65c7 Fix variable naming style in Thread fixtures
8669cc2 Merge pull request #304 from ruby/fix_parser_warnings
71c4024 Fix most parser warnings (of 317)
bb48acd Fix most parser warnings: the first 200
ddc9372 Remove bad spec potentially changing the global process group
a226ed4 Merge pull request #310 from mjago/remove_problematic_utf_8_encoding
81cbd64 Avoid problematic byte sequence in UTF-8 encoding
292f31f IO#each_codepoint raises an exception at incomplete character before EOF when conversion takes place
94cbe8d SIGTERM is not supported on Windows
2dd2245 Speed up Process.waitpid spec
67f285b Improve spec description from changelog
0c2fe01 Move Hash#inspect specs in the Hash specs
48679fe Fix shared spec name
9a6c6b1 Merge pull request #307 from sgarciac/master
aef521e Hash#inspect doesn't raise error even if its content returns a string which is not compatible with Encoding.default_external as inspected result.
894db53 flatten no longer calls #to_ary method on elements beyond the given level. * See #175 * See [Bug 10748]
8126e53 Add spec for Net::FTP being passive by default from 2.3+
6e58b5f Merge pull request #306 from mjago/setsockopt_spec_test_fail_on_osx
5c232ad getsockopt(2) returns SO_LINGER instead of 1
264f06c Fix most parser warnings: the first 100
2d5aece Fix bad spec: Module#prepend does import constants
309343b Remove usages of eval for common syntax
fc21517 AppVeyor: run only once per PR from the same repo (#305)
0d9b6ff Merge pull request #301 from nobu/suppress-warnings
1c901da Merge pull request #302 from nobu/Enumerable#chunk-without-block
e00328a Update Enumerable#chunk
75fef79 Shadowing variables
c04ce7c Suppress warnings
6852fd4 Simplify guards in pack/unpack for the special case of mingw32 on Windows 64-bit
2fd92c4 Merge pull request #300 from bkutil/test-octal-int-opal
7b19ee9 Spec for Integer("0") parsing as 0
4e37db8 Remove all not_compliant_on and deviates_on guards
66f6ccc Use a simpler limits for spec'ing too big array sizes
5c78608 Remove not_compliant_on :ironruby guards
9e0f660 Remove impl-specific object_id spec
664b4c1 Fixed one TODO
87ae44f Avoid passing RUBY_EXE explicitly
21024e4 Fix link to AppVeyor
7f7430f Mention all types of specs
0099874 Mention being tested in implementation Cis
8a29c71 Update AppVeyor badge
cab9b2f Properly convert an st_index_t to a Fixnum
de08352 Remove trailing spaces
92a66ec Replace tab by spaces
2902648 Remove extra spaces after should/should_not
52e60f4 Merge pull request #299 from backus/conditional-regexp
76f88c1 Add conditional regular expression tests
4ae1346 It seems IO#close_on_exec* was implemented on Windows in MRI 2.3
f5afc1e It seems File::Stat.ino got implemented in MRI 2.3 on Windows
3de35fe Create an empty directory for #zero? specs
d3b01ca skip hanging spec on Windows
9f78b1a Test Ruby 2.3.1 on Windows with AppVeyor
30b9fab Merge pull request #298 from ksss/interrupt
8efd3ef Add spec for inheritance of Interrupt
564a064 Add Interrupt class specs
5309c48 Merge pull request #297 from ksss/signal_exception
a79325b Check a signm value if SignalException rescued
cdd885f Merge pull request #295 from ksss/signame
d416040 Add Signal.signame specs

git-subtree-dir: spec/ruby
git-subtree-split: a2e5952554a7632e5debf0306fbae4e2559b2880
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

6 participants