Results 1 to 15 of 15

Thread: [RESOLVED] loading unicode file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Resolved [RESOLVED] loading unicode file

    Hi everyone I have a text fie contain some Unicode characters when I load the file I get a ?????? Instead of the Unicode character
    i thought internet explorer Support Unicode

    here is my code
    thanks alot

    Private Sub Form_Load()
    Open App.Path & "/" & "home.txt" For Input As #1
    WebBrowser1.Navigate "about:" & Input$(LOF(1), 1)
    Close #1
    End Sub

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: loading unicode file

    Is that a tip...???? Or a question...????

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: loading unicode file

    i have a text file contain some Unicode characters how do load them correctly in web browser
    when i open the text file i only get the question marks ?????????
    thanks

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: loading unicode file

    See if this article helps you or not... : http://support.microsoft.com/kb/193540

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: loading unicode file

    do have to use Microsoft Forms 2.0 Object to open a text file or html contain Unicode

    works fine when navigate to file
    WebBrowser1.Navigate (App.Path & "\" & "1.html")

    why doesn't work using open statement

  6. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: loading unicode file

    Quote Originally Posted by bordino View Post
    do have to use Microsoft Forms 2.0 Object to open a text file or html contain Unicode

    works fine when navigate to file
    WebBrowser1.Navigate (App.Path & "\" & "1.html")

    why doesn't work using open statement
    Try opening it in Binary mode....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  7. #7
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: loading unicode file

    This matter is a bit more complicated than you may think. If it is truly a Unicode file, it then may have a byte-order mark in it. To test this I have a bit of testing code:
    Code:
    ' Module1.bas
    Option Explicit
    
    Public Enum ByteOrderMark
        [BOM None] = 0
        [BOM Little-Endian] = &HFEFF&
        [BOM Big-Endian] = &HFFFE&
        [BOM UTF-8] = &HBFBBEF
    End Enum
    
    Public Function BOM(ByVal FilesFirstBytes As Long) As ByteOrderMark
        If (FilesFirstBytes And &HFFFF&) = [BOM Little-Endian] Then
            BOM = [BOM Little-Endian]
        ElseIf (FilesFirstBytes And &HFFFF&) = [BOM Big-Endian] Then
            BOM = [BOM Big-Endian]
        ElseIf (FilesFirstBytes And &HFFFFFF) = [BOM UTF-8] Then
            BOM = [BOM UTF-8]
        End If
    End Function
    Code:
    ' Form1.frm
    Option Explicit
    
    Private Sub Form_Load()
        Dim bytFile() As Byte, lngBOM As Long
        Open App.Path & "/" & "little-endian.txt" For Binary Access Read As #1
        'Open App.Path & "/" & "big-endian.txt" For Binary Access Read As #1
        'Open App.Path & "/" & "utf-8.txt" For Binary Access Read As #1
        'Open App.Path & "/" & "utf-8 (no bom).txt" For Binary Access Read As #1
        'Open App.Path & "/" & "windows-1252.txt" For Binary Access Read As #1
            Get #1, , lngBOM
            Select Case BOM(lngBOM)
                Case [BOM Little-Endian]
                    Debug.Print "The file is UTF-16 Little-Endian"
                    Seek #1, 3
                Case [BOM Big-Endian]
                    Debug.Print "The file is UTF-16 Big-Endian"
                    Seek #1, 3
                Case [BOM UTF-8]
                    Debug.Print "The file is UTF-8"
                    Seek #1, 4
                Case Else
                    Debug.Print "The file has no Unicode byte-order mark; it could be UTF-8 encoding or any known character set"
                    Seek #1, 1
            End Select
            ' read all of the file minus BOM
            ReDim bytFile(LOF(1) - Seek(1))
            Get #1, , bytFile
        Close #1
    End Sub
    The project is attached. Test the code against your home.txt file so we know what we are actually dealing with.
    Attached Files Attached Files

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: loading unicode file

    Hi I tried open the file in binary mode same problem
    I have saved my file as utf8 or Unicode

    This is what i have inside the file

    ها א ה 耳

    and this is what i get after i run the code

    »¿Ù

    Private Sub Command1_Click()
    Dim f As Long
    Dim x(3) As Byte
    Dim readresult As String

    f = FreeFile()
    Open "C:\home.txt" For Binary As #f

    Get #f, , x
    Close #f
    readresult = Chr(x(0)) & Chr(x(1)) & Chr(x(2)) & Chr(x(3))
    Web.Navigate readresult
    End Sub

  9. #9
    Lively Member agent_007's Avatar
    Join Date
    Jan 2010
    Posts
    93

    Re: loading unicode file

    Quote Originally Posted by bordino View Post
    Hi everyone I have a text fie contain some Unicode characters when I load the file I get a ?????? Instead of the Unicode character
    i thought internet explorer Support Unicode

    here is my code
    thanks alot

    Private Sub Form_Load()
    Open App.Path & "/" & "home.txt" For Input As #1
    WebBrowser1.Navigate "about:" & Input$(LOF(1), 1)
    Close #1
    End Sub
    Try This

    Code:
    Private Sub Command1_Click()
    Dim f As Long
    Dim read As String
    f = FreeFile()
    Open "C:\home.txt" For Binary As #f
    read = InputB(10, #f)
    Close #f
    Web.Navigate "about:" & read
    End Sub

    Im Pro in C#,VB.NET,Batch,Socket Programming, SPY Software Programming, VB6, Win32Api, VBscript, Windows Registry, ASP.NET, PHP, Jquery, AJAX.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: loading unicode file

    i get this when i run you code
    믯��₧郗휠ₔ胨₳

    instead of this
    ها א ה 耳

    thanks alot

  11. #11
    Lively Member agent_007's Avatar
    Join Date
    Jan 2010
    Posts
    93

    Re: loading unicode file

    Quote Originally Posted by bordino View Post
    i get this when i run you code
    믯₧郗휠ₔ胨₳

    instead of this
    ها א ה 耳

    thanks alot
    try saving the file in unicode and not in utf-8 or unicode big indian

    Im Pro in C#,VB.NET,Batch,Socket Programming, SPY Software Programming, VB6, Win32Api, VBscript, Windows Registry, ASP.NET, PHP, Jquery, AJAX.

  12. #12
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: loading unicode file

    Try code in post #7 and tell the results or upload home.txt

  13. #13
    Lively Member agent_007's Avatar
    Join Date
    Jan 2010
    Posts
    93

    Re: loading unicode file

    if problem doesnt solve then upload home.txt

    Im Pro in C#,VB.NET,Batch,Socket Programming, SPY Software Programming, VB6, Win32Api, VBscript, Windows Registry, ASP.NET, PHP, Jquery, AJAX.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: loading unicode file

    thanks sooooooooo mouch man you right after saved in Unicode works perfect

  15. #15
    Lively Member agent_007's Avatar
    Join Date
    Jan 2010
    Posts
    93

    Re: loading unicode file

    Quote Originally Posted by bordino View Post
    thanks sooooooooo mouch man you right after saved in Unicode works perfect
    Ur Welcome and mark the thread as resolved

    Im Pro in C#,VB.NET,Batch,Socket Programming, SPY Software Programming, VB6, Win32Api, VBscript, Windows Registry, ASP.NET, PHP, Jquery, AJAX.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width