biud436 / vscode-rgss-script-compiler

🏰 RGSS Script Compiler is the extension of Text Editor called Visual Studio Code. if you are using this extension, you can modify script files and create the bundle file called Scripts.rvdata2 in Visual Studio Code without internal Script Editor directly.
https://marketplace.visualstudio.com/items?itemName=biud436.rgss-script-compiler
MIT License
13 stars 3 forks source link

fix(RGSS3): incompatible character encodings: UTF-8 and ASCII-8BIT #23

Closed biud436 closed 6 months ago

biud436 commented 6 months ago

If the filename contains Korean characters that includes non ASCII, you will see the following error (Windows 11 + OneDrive)

The current extension path is c:\Users\biud4\.vscode\extensions\biud436.rgss-script-compiler-0.9.2.
[file changed] {"$mid":1,"fsPath":"c:\\Users\\biud4\\OneDrive\\문서\\RPGVXAce\\VXA\\Scripts\\121-RS_GlareEffect.rb","_sep":1,"path":"/c:/Users/biud4/OneDrive/문서/RPGVXAce/VXA/Scripts/121-RS_GlareEffect.rb","scheme":"file"}
incompatible character encodings: UTF-8 and ASCII-8BIT

As a result of this error, creating a file like Scripts.rvdata2 will fail.

In the aftermath,

biud436 commented 6 months ago
image
        files = []
        if File.exist? File.join(indir, 'info.txt')
            input = File.open(File.join(indir, 'info.txt'), 'rb')
            input.read.each_line do |line|
                filename = line.gsub("\n", '') # it is always ASCII-8BIT
                filename.force_encoding('utf-8')

                files.push(File.join(indir, filename))
            end
            input.close
        else
            files = Dir.glob(File.join(indir, '*.rb'))
        end