Is there a way to use character encoding that's not UTF-8?

I am trying to make a Jekyll site where the contact form is in Japanese Shift-JIS character encoding, not UTF-8 (REASON: my homepage service has a free-of-charge form decode cgi which expects the input to be Shift JIS, not UTF-8. When I use UTF-8 for the form, the email that gets sent from the HTML form becomes garbled).

Unfortunately, Jekyll seems to expect all files to be in UTF-8 and I get the error message “invalid byte sequence in UTF-8”. Is there a way around this? Thanks for any help!:

chapintokyo@x230-i7:~/Documents/GitHub/jana$ bundle exec jekyll serve --trace
Configuration file: /home/chapintokyo/Documents/GitHub/jana/_config.yml
            Source: /home/chapintokyo/Documents/GitHub/jana
       Destination: /home/chapintokyo/Documents/GitHub/jana/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
Error reading file /home/chapintokyo/Documents/GitHub/jana/contact_sjis.html: invalid byte sequence in UTF-8 
       Jekyll Feed: Generating feed for posts
  Liquid Exception: invalid byte sequence in UTF-8 in contact_sjis.html
bundler: failed to load command: jekyll (/home/chapintokyo/gems/bin/jekyll)
Traceback (most recent call last):
        48: from /home/chapintokyo/gems/bin/bundle:23:in `<main>'
        47: from /home/chapintokyo/gems/bin/bundle:23:in `load'
        46: from /home/chapintokyo/gems/gems/bundler-2.3.26/exe/bundle:36:in `<top (required)>'
        45: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
        44: from /home/chapintokyo/gems/gems/bundler-2.3.26/exe/bundle:48:in `block in <top (required)>'
        43: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/cli.rb:25:in `start'
        42: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        41: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/cli.rb:31:in `dispatch'
        40: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        39: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        38: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        37: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/cli.rb:486:in `exec'
        36: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:23:in `run'
        35: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:58:in `kernel_load'
        34: from /home/chapintokyo/gems/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:58:in `load'
        33: from /home/chapintokyo/gems/bin/jekyll:23:in `<top (required)>'
        32: from /home/chapintokyo/gems/bin/jekyll:23:in `load'
        31: from /home/chapintokyo/gems/gems/jekyll-4.3.1/exe/jekyll:15:in `<top (required)>'
        30: from /home/chapintokyo/gems/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        29: from /home/chapintokyo/gems/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        28: from /home/chapintokyo/gems/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        27: from /home/chapintokyo/gems/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        26: from /home/chapintokyo/gems/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        25: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
        24: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        23: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/command.rb:91:in `each'
        22: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        21: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/commands/build.rb:36:in `process'
        20: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/commands/build.rb:65:in `build'
        19: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/command.rb:28:in `process_site'
        18: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/site.rb:80:in `process'
        17: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/site.rb:211:in `render'
        16: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/site.rb:569:in `render_pages'
        15: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/site.rb:569:in `each'
        14: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/site.rb:570:in `block in render_pages'
        13: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/site.rb:578:in `render_regenerated'
        12: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/renderer.rb:63:in `run'
        11: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/renderer.rb:80:in `render_document'
        10: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/renderer.rb:124:in `render_liquid'
         9: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/liquid_renderer/file.rb:12:in `parse'
         8: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time'
         7: from /home/chapintokyo/gems/gems/jekyll-4.3.1/lib/jekyll/liquid_renderer/file.rb:13:in `block in parse'
         6: from /home/chapintokyo/gems/gems/liquid-4.0.3/lib/liquid/template.rb:116:in `parse'
         5: from /home/chapintokyo/gems/gems/liquid-4.0.3/lib/liquid/template.rb:132:in `parse'
         4: from /home/chapintokyo/gems/gems/liquid-4.0.3/lib/liquid/template.rb:226:in `tokenize'
         3: from /home/chapintokyo/gems/gems/liquid-4.0.3/lib/liquid/template.rb:226:in `new'
         2: from /home/chapintokyo/gems/gems/liquid-4.0.3/lib/liquid/tokenizer.rb:8:in `initialize'
         1: from /home/chapintokyo/gems/gems/liquid-4.0.3/lib/liquid/tokenizer.rb:23:in `tokenize'
/home/chapintokyo/gems/gems/liquid-4.0.3/lib/liquid/tokenizer.rb:23:in `split': invalid byte sequence in UTF-8 (ArgumentError)

This is not something I am familiar with, but it does look like Jekyll offers the ability to encode pages. Here is the reference:

I ran the recommended code Ruby code, and as you can see in the image, Shift_JIS is supported. You will have to use Ruby 1.9 or greater.

Thank you so much! I will try this out!

1 Like