Failed to read RBE/RBS file - Unicode character in username (Windows, SU2016)

Failed to read RBE/RBS file - Unicode character in username (Windows 7, SU2016)

Getting this error in SketchUp Make 2016 when trying to load an RBS file in a path containing Unicode characters (username is “HD INFORMÁTICA” in the example below). Tested in Windows 7 32-bit but I believe the same would happen in other Windows versions, 32 or 64-bit. RBS file was generated with the scrambler found here. Works fine if placed in a path without Unicode characters.

Error Loading File C:/Users/HD INFORMÁTICA/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/bimbon/main.rbs
Failed to read RBE/RBS file.

Is there a way to load an RBS file in a Windows path with Unicode characters? Or the only way is to use an RB file instead of an RBS one? Or maybe there’s something wrong in my code? force_encoding("UTF-8") wasn’t enough to fix this error.

I know about the %ProgramData% workaround but I would rather not have to ask users in this situation to move files around…

Any help is appreciated
Thanks

Extension folder structure:

bimbon/
bimbon/icon.png
bimbon/lib/
bimbon/lib/sketchup_json/
bimbon/lib/sketchup_json/generator.rb
bimbon/lib/sketchup_json/parser.rb
bimbon/loader.rb
bimbon/main.rbs
bimbon/reload.png
bimbon.rb

Relevant files below.

bimbon.rb:

# encoding: utf-8
module Bimbon
  current_path = File.dirname(__FILE__)
  if current_path.respond_to?(:force_encoding)
    current_path.force_encoding("UTF-8")
  end

  VERSION          = "1.0"
  MAINFILE         = "main.rbs"
  PLUGIN_ROOT_PATH = current_path.freeze
  PLUGIN_PATH      = File.join(PLUGIN_ROOT_PATH, 'bimbon').freeze
end

Sketchup::require "extensions"
bimbon_extension = SketchupExtension.new("bim.bon", File.join(Bimbon::PLUGIN_PATH, "loader.rb"))
bimbon_extension.version = Bimbon::VERSION
bimbon_extension.creator = "..."
bimbon_extension.copyright = "..."
bimbon_extension.description = "..."
Sketchup.register_extension(bimbon_extension, true)

bimbon/loader.rb:

# encoding: utf-8
Sketchup::require "bimbon/main"

Can’t find the reference just now, but I believe this issue has been reported and Trimble has acknowledged it.

Try:

current_path = File.dirname(__FILE__)
if defined?(Encoding)
  current_path = current_path.force_encoding("UTF-8")
end

That might force the re-encoding in the newer versions of SketchUp…

Just tried and… same error.

Not sure why but it seems to be an RBE/RBS specific error. If I place a main.rb file in the same path it works just fine.

Also, it only happens in SketchUp 2016. The same extension loads without any errors in SketchUp 2015, 2014 and 2013.

Thanks for your help

Correct. SketchUp SU2016 M0 had an regression error that prevented any RBS/RBE files from loading from path with multi-byte characters.

It is unrelated to the general bug in Ruby itself where it labels strings from __FILE__ and ENV with the wrong encoding.

Thanks all for your time and help. I will wait for M1 then.

Cheers

1 Like