Re: [OT] Using DIR (CMD) with redirection to a file

new topic     » goto parent     » topic index » view thread      » older message » newer message
znorq2 said...

Hi kinz,

When opening the console, default code page is 850. According to this page sent to me earlier, 865 (Nordic) is probably the one I should change to before running the DIR command...

Your default code page 850 seems to be namely OEM (DOS) code page, but cp865 seems to be some code page with win-1252 encoding for "æøåÆØÅ" letters.

The DIR command uses strongly OEM encoding.

znorq2 said...

This is what I did;

  1. Created folder "æøåÆØÅ" under "c:\data\test".
  2. Opened console (cmd)
  3. Changed to "c:\data\test"
  4. Confirmed current code page 850 (using chcp w/o params.)
  5. chcp 865

Try the chcp w/o params to see if cp was changed to 865 really.

znorq2 said...
  1. dir *.* /b > files.txt
  2. Opened "files.txt" using notepad.
  3. Changed to font to "Terminal".

OK, Terminal has strongly OEM encoding.

znorq2 said...


Letters "æøåÆØÅ" are now visible.

So, DIR worked in OEM (850).

znorq2 said...

I use Font "Lucida Console" / Script "Western" as a default (did a little research, and this is the default font/script setting for everybody..), and æøåÆØÅ is perfectly usable characters in this font. But, when æøåÆØÅ is routed through DIR's redirection, it becomes garbled. Apperantly, they have a different byte representation in Western script compared to OEM/DOS? If so, it seems I have to go through the file replacing it with the correct byte representation for "Lucidia Concole / Western", (which shouldn't really be a problem..)?

"Lucida Console" has Windows encoding 1251 here, in Russia, so yours one works same way, on cp1252, and can not display OEM text properly, I think.

I use recoding to write and read Russian file names in EU.
The ed editor works as OEM thing, so recodind is not needed, but if I program in, say, Notepad or Edita or such a Windows editor, I need recode from 1251 to 866 the file names and Russian output of DIR, if I want to read output in Notepad or Edita without changeing the font to Terminal.

znorq2 said...

That said, I would have used Euphoria - and not Console/DIR, but I've got no idea how I can produce the information I'm after (with the exception of path/filename, ofcourse);

  1. Created date/time
  2. Created by
  3. Filename/path

Try the function below, it is not tested, but gives the idea, I hope.

constant W = {#E6,#F8,#E5,#C6,#D8,#C5}, -- codes of your letters in 1252 
         O = {#91,#9B,#86,#92,#9D,#8F}, -- codes of same letters in 850 
    W_to_O = 1, -- mode from Windows to OEM 
    O_to_W = 2  -- mode from OEM to Windows 
 
function recode_nor(sequence input, -- input text (command or DIR output) 
                      integer mode) -- W_to_O, or O_to_W 
integer c, d 
  for i=1 to length(input) do 
     c = input[i] 
       if mode = W_to_O then 
           d = find(c, W) 
             if d then 
                 input[i]= O[d] 
             end if 
       end if 
       if mode = O_to_W then 
           d = find(c, O) 
             if d then 
                 input[i]= W[d] 
             end if 
       end if 
   end for 
  return input 
end function 


Regards,
kinz

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu