French OS Compatibility Issue

I have a customer who has installed my plugins on a French Canadian Windows 10 OS and is getting the following error in both the French and English versions of SketchUp Make 2017:

I’ve never seen this error before and it appears to be related to the French OS.

Has anyone ever seen this sort of thing before? Solution?

Could it be due to having binaries installed/located on both the C: and D: drives?

The user’s name contains an accented character - “benoît”

In the past this was the kiss-of-death to Ruby on PCs, however changes to Ruby have covered a lot [if not all] such cases…
The clue is also in the start of the error-message - “…mismatch… UTF-8 regexp with Windows-1252 string…
Without seeing your code it has to be a guess, but I suspect that you are somehow passing a string-path to part of your code which is NOT forced its encoding into UTF-8

Whenever you get a string reference to a path - especially in the user’s AppData tree - it’s vital to immediately force its encoding correctly…
e.g.

ME = __FILE__.force_encoding("UTF-8")

which returns a loaded script’s full-path into a Constant ME - e.g. the file in its main folder
From that you can parse out its folder-path, or create a reference to nested folder with it etc… e.g.

MY_DIR = File.dirname(ME)
MY_MATS = File.join(MY_DIR, "Materials")
1 Like

Same error from another user in Russia, his username is: peter novák

Looks like I need to figure this one out and fully address it.

The chunk of code were I probably need to address this is here:

############
# Initialization Check for Wall Plugin Parameters

WIN_OS = ( Sketchup.platform == :platform_win rescue RUBY_PLATFORM !~ /(darwin)/i )
if WIN_OS
          appdata = ENV['AppData'].gsub(/(\\\\|\\)/,'/')
else
          appdata = File.expand_path('~/Library/Application Support')
end

su_version = Sketchup.version.to_i + 2000
    		
APPDATA_MEDEEK_WALL = File.join(appdata,"Medeek/#{su_version}/medeek_wall_ext")

I’m doing something similar here already with this chunk of code:

this_dir = File.dirname(__FILE__)
	# Fix for ruby 2.0
	if this_dir.respond_to?(:force_encoding)
		THIS_DIR = this_dir.dup.force_encoding("UTF-8")
	else
		THIS_DIR = this_dir
	end

So my first chunk of code should be updated to?

############
# Initialization Check for Wall Plugin Parameters

WIN_OS = ( Sketchup.platform == :platform_win rescue RUBY_PLATFORM !~ /(darwin)/i )
if WIN_OS
      	appdata = ENV['AppData'].gsub(/(\\\\|\\)/,'/')
else
      	appdata = File.expand_path('~/Library/Application Support')
end

if appdata.respond_to?(:force_encoding)
	APPDATA = appdata.dup.force_encoding("UTF-8")
else
	APPDATA = appdata
end

su_version = Sketchup.version.to_i + 2000
		
APPDATA_MEDEEK_WALL = File.join(APPDATA,"Medeek/#{su_version}/medeek_wall_ext")

I guess I’m still not clear on what is going on here. With this particular line of code why the need for “dup” method?

I think it came from someone’s attempt to not modify the strings in the ENV hash.

But in your case String#gsub creates a new method anyway.
And I think the same for File::expand_path method.

The encoding output by these methods may be dependent upon what you use for a script encoding.
This is why it is strongly suggested you use a “magic comment” at the tippy top of every file. IE …

# encoding: UTF-8

Suggested reading is the preamble to the Encoding class.

1 Like