title: Excel VBA Read txt files to string variable - Multiple Languages
body: <p>I try to read mutiple txt files with Excel VBA and store their file name and content in an array. However I have a hard time with character sets, since the txt file can contain a variety of languages. Is there a charset that supports all languages or how can I solve the below described problem?</p>
  <p>Here is the code I have</p>
  <pre><code>Function create_Txt_Content_Array(file_count As Integer, path As String, Optional strType As String) As String()
  
  Dim createArray() As String
  Dim file As Variant
  Dim read_file As Integer
  Dim absolut_path As String
  Dim i, j As Integer
  Dim text_content As String
  Dim objStream
  
  Set objStream = CreateObject(&quot;ADODB.Stream&quot;)
  objStream.Charset = &quot;utf-8&quot;
  
  ReDim createArray(file_count - 1, 1)
  
      If Right(path, 1) &lt;&gt; &quot;\&quot; Then path = path &amp; &quot;\&quot;
      file = Dir(path &amp; strType)
      absolut_path = path &amp; file
      j = 0
      While (file &lt;&gt; &quot;&quot;)
          objStream.Open
          objStream.LoadFromFile (absolut_path)
          text_content = objStream.ReadText()
          objStream.Close
          createArray(j, 0) = file
          createArray(j, 1) = text_content
          Debug.Print (text_content)
          i = i + 1
          j = j + 1
          file = Dir
          absolut_path = path &amp; file
      Wend
      
      Set objStream = Nothing
  
  End Function
  </code></pre>
  <ul>
  <li>The first file contains Portuguese: no problem</li>
  <li>The second file contains English: no problem</li>
  <li>The third file contains Hindi: not working</li>
  </ul>
  <p>There are other languages like Korean, Japanese and others following.</p>
  <p><a href="https://i.stack.imgur.com/JV4ta.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JV4ta.png" alt="This is what the array looks like" /></a></p>