Skip to content

Instantly share code, notes, and snippets.

@Inversion-des
Last active July 9, 2021 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Inversion-des/75949795cc5be707c19d31901e79d1cf to your computer and use it in GitHub Desktop.
Save Inversion-des/75949795cc5be707c19d31901e79d1cf to your computer and use it in GitHub Desktop.
# ц
puts `chcp`
p Encoding.default_external
p file:__FILE__
p dir:__dir__
puts '-'*10
p LOAD_PATH:$LOAD_PATH[0]
p start_with:$LOAD_PATH[0].start_with?(__dir__)
# ----- workaround --------------------------------------------------------
# p Gem_dir:Gem.dir
# Gem.dir.force_encoding("UTF-8")
# p Gem_dir:Gem.dir
# p Gem_path:Gem.path
# Gem.path.each {|path| path.force_encoding 'UTF-8' }
# p Gem_path:Gem.path
# if $:[0].encoding.name == 'Windows-1251'
# $:.each {|path| path.encode! 'UTF-8' }
# $:.push '.' # somehow it helps, looks like a modification of array is needed
# end
# ----- /workaround --------------------------------------------------------
# puts 'bundler/setup'
# # fails: incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
# require 'bundler/setup'
puts '='*10
require_relative 'f2'
# ц
puts `chcp`
p Encoding.default_external
p file:__FILE__
p dir:__dir__
puts '-'*10
p LOAD_PATH:$LOAD_PATH[0]
# fails: incompatible character encodings: Windows-1251 and UTF-8 (Encoding::CompatibilityError)
p start_with:$LOAD_PATH[0].start_with?(__dir__)
# fails: incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)
p start_with:$LOAD_PATH[0].start_with?(Gem.dir)
puts 'bundler/setup'
# fails: incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
p require 'bundler/setup'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment