"require set " error

sketchup

#1
# coding: utf-8

require 'sketchup'
require 'set'

Encoding.default_external='utf-8'

when i install sketchup into the directory with chinese character, the sketchup plugin loads with errors when i require set. I guess the set library is in the installation’s directory. but the path has other characters not ascill. so is it a bug for sketchup?

Error: #<Encoding::UndefinedConversionError: "\xAF\xE4" from GBK to UTF-8>
c:/users/vic/appdata/roaming/sketchup/sketchup 2015/sketchup/plugins/sk_building_client.rbs:4:in `require'
c:/users/vic/appdata/roaming/sketchup/sketchup 2015/sketchup/plugins/sk_building_client.rbs:4:in `<main>'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `eval'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `require'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `block in require_all'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `each'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `require_all'
<main>:in `<main>'
SketchUp:1:in `eval'

#2

When i replace the “Set” with “Sketchup::Set”, i don’t require set in standard library. but when i require ‘logger’, it also has the same problem. what can i do?


#3

Before any requires, try adding

$LOAD_PATH.map! { |d| d.dup.force_encoding('UTF-8') }

You may have to repeat it if the $LOAD_PATH array changes. I believe it’s a Ruby issue. SU 2017 also seems to have the same issue, the above fix works for it. Don’t have SU 2015 installed…


#4

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.