Character encoding issues UTF8

I’m tearing my hair out with this and hoping someone can help. I keep getting weird character encoding issues when using dashes in urls or files. e.g.

<% content_for :stylesheet do %>
  <%= stylesheet_link_tag("gang-starr–battle.css") %>
<% end %>

Is actually output as…

http://0.0.0.0:4567/stylesheets/gang-starr–battle.css

So I’m getting 404 errors on my stylesheets.

The same thing with frontmatter and outputting navigation e.g. this

---
title: Gang Starr – Battle
player_color: e70000
track: gang starr battle
---

<% pages = sitemap.resources.find_all{|p| p.source_file.match(/\.html/)}.sort_by {|p| p.url} %>
<ul>
  <% pages.each do |p| %>
    <% if(p.data.title) %>
      <li>
        <%= link_to p.data.title, p.url.force_encoding(Encoding::UTF_8) %>
      </li>
    <% end %>
  <% end %>
</ul>

Only works as I’m force encoding UTF8, if I take that out I get the same character encoding issues and the pages are not recognised.

I’ve tried forcing encoding at the top of my config.rb, and per erb file but no joy.

Using middleman 3.2.2 and ruby-2.0.0-p353

So it turns out for some unknown reason all my file names had a mix of em and en dashes. Have no idea how it occurred but after batch rename of everything I’m back up an running again. So weird

A character encoding tells the computer how to interpret raw zeroes and
ones into real characters. It usually does this by pairing numbers with
characters. Words and sentences in text are created from characters and
these characters are grouped into a character set. There are many
different types of character encodings floating around at present, but
the ones we deal most frequently with are ASCII, 8-bit encodings, and
Unicode-based encodings. More about…Character Encoding

Kerry