dcsimg
Results 1 to 4 of 4

Thread: Read Chinese characters in directory path

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2018
    Posts
    6

    Read Chinese characters in directory path

    Hi,

    can anybody share with me how to handle chinese characters in directory path? is there some decoding i have to do to make it UTF-8, something like that?
    I tried path with English, the code below works.

    Code:
    Dim fso
    Dim fldr
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldr = fso.GetFolder("C\\network folder\Share\出口共享\some chinese characters")
    MsgBox "Number of contracts found till date: " & fldr.SubFolders.Count
    thanks

  2. #2
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    617

    Re: Read Chinese characters in directory path

    We were assuming Visual Basic 6 since this is a Vb6 forum.

    This script in Notepad (Save As Unicode) "FSOChinese.vbs" works without conversion.
    You do not need to play with Fonts. Just paste your Unicode path within quotes, Save As Unicode, and it should work.
    This example uses relative path so has to run where the folder is.
    Otherwise use a full path.

    Code:
    Dim fso
    Dim fldr
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    Set fldr = fso.GetFolder("中文")
    MsgBox "Number of contracts found till date: " & fldr.SubFolders.Count
    Perhaps you are saving as ANSI (MBCS), which may look OK on Chinese OS but won't work.
    You must save as Unicode. In Notepad, use Save As and select Unicode from the Encoding DropDown combo.
    Last edited by DrUnicode; Aug 31st, 2018 at 12:11 PM. Reason: Added [CODE] tags

  3. #3
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    617

    Re: Read Chinese characters in directory path

    If you are using Notepad++, open Encoding and select "Encode in UCS-2 LE BOM" before Save.

    Name:  Notepad++Chinese.jpg
Views: 58
Size:  25.0 KB

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2018
    Posts
    6

    Re: Read Chinese characters in directory path

    absolutely grateful.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width