<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Windows filenames should be in UTF-8 encoding"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=103536">103536</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Windows filenames should be in UTF-8 encoding
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>cairo
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>win32 backend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>cairo-bugs@cairographics.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Tom.Schoonjans@me.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>cairo-bugs@cairographics.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Currently all cairo functions involving writing or reading from files, use the
fopen call to access those files. This works fine on Linux and macOS, but is
troublesome on Windows since it assumes that the filename string is encoded in
the ANSI codepage (see
<a href="https://msdn.microsoft.com/en-us/library/yeby3zcb.aspx#Anchor_2">https://msdn.microsoft.com/en-us/library/yeby3zcb.aspx#Anchor_2</a> for more on
this).

This means that UTF-8 encoded filenames cannot be passed to these cairo
methods, since any non-ASCII characters will be misinterpreted leading to
run-time fopen errors (file not found etc). This is particularly unfortunate
when writing cross platform software using Gtk+/Glib, which use UTF-8 filenames
throughout the API. 

Keeping in mind that Microsoft is actively discouraging the reliance on
codepages
(<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx</a>),
I was wondering if the cairo maintainers would be willing to accept a patch
that fixes this issue by switching to the internal usage of _wfopen
(<a href="https://msdn.microsoft.com/en-us/library/yeby3zcb.aspx">https://msdn.microsoft.com/en-us/library/yeby3zcb.aspx</a>) for the Windows
platform, which would convert the UTF-8 filenames to their UTF-16 wide
character string counterparts that will then be passed to _wfopen, very similar
to what glib does with its g_fopen function.

I actually already found a 10 year old patch on the mailing list
(<a href="https://lists.cairographics.org/archives/cairo/2007-February/009591.html">https://lists.cairographics.org/archives/cairo/2007-February/009591.html</a>),
which was unfortunately never merged in, and may serve as a starting point for
a new patch, compatible with the master branch.

I would be more than willing to perform the necessary work for this.

Thanks in advance for your reply,

Tom</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>