Announcement

Collapse
No announcement yet.

DIR and code page. Help need

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DIR and code page. Help need

    Folks,

    I'm completely lost!
    I need to get the list of all folders with subfolders. Nothing complex. I'm stuck with codepage!
    The code page on running machine is 850. System command DIR returns ??? signs instead of correct symbols (russian characters) for file/folder names. They're visible and readable via windows explorer.

    I tried following methods:

    1. SHELL "dir ...."
    2. SHELL "chcp 866 | dir ...."
    3. FindFirstW (unicode version, tested almost every code posted here... )

    an the result wasn't acceptable. I don't know where to dig to get the correct symbols..

    I can read the file/folder names only if run XCOPY command in console. That's strange, as DIR cmd didn't show them.

    Are there any other methods to get the correct filenames?

  • #2
    Directory List with Non-ASCII (Unicode) characters in file names 5-31-08

    Your problem may not be so much "getting" the correct filenames as it is "displaying" them. If your display medium is not Unicode-enabled you will get crap on your screen even if your file names are "correct" within your program.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Unicode enabled? That might be the an issue. I'm not sure if that machine is unicode enable, but anyway, this is a WinXP SP2 machine, so unicode settled by default.

      I've tested and adopted your code at first. I got results, but it stops on first non-english filenames/folders. I redirected the output to a binary file, not to display.

      Comment


      • #4
        "stop" means....????

        Also show failing code.

        If you dumped that output to a file, and then tried to read it as text, it will 'appear' truncated at the first null. Open it with a hex editor. And don't use ASCIIZ datatypes .
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Would this be of any help?

          Code:
          Declare Function AreFileAPIsANSI Lib "KERNEL32.DLL" Alias "AreFileApisANSI" () As Long
          
          Function SetCharsTo(ByVal CharSet As String) As String
             'accepts a string of A or O; returns A or O to indicate which is set
             Local lRet As Long
          
             If UCase$(Left$(CharSet, 1)) = "A" Then        'use this when parsing from a DOS or DIR$ result    ????
                lRet = AreFileApisANSI()
                If lRet = 0 Then
                   SetFileApisToANSI()
                End If
                Function = "ANSI"
             ElseIf UCase$(Left$(CharSet, 1)) = "O" Then    'use this when parsing from a file made by external program  ????
                lRet = AreFileApisANSI()
                If lRet <> 0 Then
                   SetFileApisToOEM()
                End If
                Function = "OEM"
             End If
          End Function

          Comment


          • #6
            Michael, John,

            Thanks for your replies. Finally, i found a problem. I didn't converted the initial filemask string to unicode.

            Aslan.

            Comment

            Working...
            X