0

I am trying to read a plaintext store as UTF-8 and split it into slides in PowerPoint. However, my text doesn't work. Persian is a subset of Arabic typesetting codes.

Function convertANSIPersiande(inputStr As String) As String
    Dim n As Integer
    Dim i As Integer
    Dim inBytes() As Byte
    Dim sUnicode As String
    
    ' Convert input string to byte array
    n = Len(inputStr)
    ReDim inBytes(n + 1)
    
    For i = 1 To n
        inBytes(i) = AscB(Mid(inputStr, i, 1))
    Next
    
    ' Convert byte array to unicode using Persian coding
    sUnicode = StrConv(inBytes, vbUnicode, &H429)
    
    ' remove starting null
    iPos = InStr(sUnicode, Chr(0))
    If iPos > 0 Then sUnicode = Mid(sUnicode, iPos + 1)
    
    convertANSIPersian2Unicode = sUnicode

End Function

Now when I write

pptTable.Table.Cell(1, Count Mod 2).Shape.TextFrame.TextRange.Text = convertANSIPersian2Unicode(DataLine)

The text is a gibberish mix of Arabic characters with special chars. I have Widnows 10 set to show Persian text.

Any help would be greatly appreciated.

chikitin
  • 762
  • 6
  • 28
  • How about using adodb.stream. Refer [This](https://stackoverflow.com/questions/64783621/import-tab-separated-csv-tab-delimiter-not-recognized/64831319#64831319) – Dy.Lee Nov 30 '20 at 00:22
  • Thank you very much. It worked like a charm! I was wondering if there is a keyword for the FreeFile() to read UTF-8 text! That would be much easier! – chikitin Nov 30 '20 at 01:24

0 Answers0