title: How do file names work between `char` and 2-byte characters?
body: <p>I'm creating a wrapper for <code>boost::filesystem</code> for my application. I'm investigating what's going to happen if I have some non-ASCII characters in the file names.</p>
  
  <p>On Windows, <a href="http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/reference.html#path-native-format-observers" rel="nofollow noreferrer">the documentation</a> says that all characters are <code>wchar_t</code>. That's very understandable and coherent.</p>
  
  <p>But on Linux, the <a href="http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/reference.html#path-native-format-observers" rel="nofollow noreferrer">the documentation</a> says that all characters are <code>char</code>! So 1-byte characters. I was wondering, will this even work and read non-ASCII characters? So I created a directory with an Arabic name <code>تجريب</code> (It's a 5-letter word), and read it with <code>boost::filesystem</code>. I printed that in the terminal, and it worked fine (apart from that the terminal, terminator, wrote it incorrectly as left-to-right). The printed result on the terminal was:</p>
  
  <pre><code>/mnt/hgfs/D/تجريب
  </code></pre>
  
  <p>Something doesn't add up there. How could this be 1-byte <code>char</code> string, and still print Arabic names? So I did the following:</p>
  
  <pre><code>std::for_each(path.string().begin(), path.string().end(), [](char c) {
      std::cout&lt;&lt;c&lt;&lt;std::endl;
  });
  </code></pre>
  
  <p>And running this gave where <code>path</code> is the directory I mentioned above, gave:</p>
  
  <pre><code>/
  m
  n
  t
  /
  h
  g
  f
  s
  /
  D
  /
  �
  �
  �
  �
  �
  �
  �
  �
  �
  �
  </code></pre>
  
  <p>And at this point, I really, really got lost. The Arabic word is 10 bytes, which creates a 5-letter word. </p>
  
  <p><strong>Here comes my question</strong>: Part of the characters are 1-byte, and part of the characters are 2-bytes. How does linux know that those 2-characters are a single 2-byte character? Does this mean that I never need to have a 2-byte character on linux for its file system, and <code>char</code> is good for all languages?</p>
  
  <p>Could someone please explain how this works?</p>