Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Simplified issue:

I have a file called Bíblia sagrada.exe (note the í) on C:\ of my computer.

When I open a command prompt on C:\ and execute dir /b /on B*.*, it will return:

Bíblia sagrada.exe

i.e., no issues with diacritic symbols.

But when I do dir /b /on B*.* > c:\a.txt and open c:\a.txt with Notepad, it becomes:

B¡blia sagrada.exe

i.e., it replaces í with ¡.

And if I perform for /f "delims=" %i in ('dir /b /on B*.*') do %i > %i.txt it puts the correct name in the filename but inside it the text is still wrong, i.e.,

Filename:

Bíblia sagrada.exe.txt

Contents:

B¡blia sagrada.exe

What's going on?

PS:

Real issue

The issue for me is worse than I reported on first edit, because I read the contents of a txt file to create a .vbs script and then to execute it; when trying to execute, "it doesn't understand" that it points to "Bíblia sagrada.exe" and it does not execute the program... i.e., I created a .bat on d:\atalhizador\atalhizador.bat:

@echo off

::locais
set drvbak=
set drvprogrs=
set pathbak=%cd%
set pathabove=
set pathprogrs=%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

::identificador da pasta do programa no menu iniciar
set id=_pext1

::determina drives de acordo com paths
for /f "delims=" %%z in ("%pathbak%")    do set drvbak=%%~dz
for /f "delims=" %%z in ("%pathprogrs%") do set drvprogrs=%%~dz

::pega caminho superior
cd..
set pathabove=%cd%
cd %pathbak%

cls
echo.***************
echo.* ATALHIZADOR *
echo.***************
echo.
echo.Deseja realmente executar o atalhizador para a pasta:
cd..
echo.  %cd%
cd %pathbak%
echo. [s/n]:
set /p ___o=
if not "%___o%"=="s" if not "%___o%"=="S" goto end

echo.
echo.Criando os atalhos...
for /f "delims=" %%a in ('dir /b /ad /on ..') do (
  echo.- pasta "%%a"...
  echo.  ^|-- buscando arquivos atalhizaveis...
  if not exist "temp" mkdir "temp"
  dir /b /on "..\%%a\*.exe" 1>temp\busca.txt 2>temp\erros.txt
  for /f "delims=" %%b in (temp\busca.txt) do (
    echo.      ^|-- criando atalho para %%b

    for /l %%z in (1,1,1) do set __temp__=

    if not exist "%pathprogrs%\%id%" mkdir "%pathprogrs%\%id%"
    if not exist "%pathprogrs%\%id%\%%a" mkdir "%pathprogrs%\%id%\%%a"

    echo.Set oWS = WScript.CreateObject^("WScript.Shell"^) > temp\%%~na-%%~nb.vbs
    echo.sLinkFile = "%pathprogrs%\%id%\%%a\%%b.lnk" >> temp\%%~na-%%~nb.vbs
    echo.Set oLink = oWS.CreateShortcut^(sLinkFile^) >> temp\%%~na-%%~nb.vbs
    echo.oLink.TargetPath = "%pathabove%\%%a\%%b" >> temp\%%~na-%%~nb.vbs
    echo.oLink.Save >> temp\%%~na-%%~nb.vbs

    cscript /nologo temp\%%~na-%%~nb.vbs
  )
)

:end
%drvbak%
cd %pathbak%

pause
@echo off

The mentioned "Bíblia sagrada.exe" is in d:\Bíblia sagrada.

The generated .vbs file is below (suppose that there are only these two directories on d:), with filename D:\atalhizador\temp\Bíblia Sagrada-Bíblia Sagrada.vbs:

Set oWS = WScript.CreateObject("WScript.Shell") 
sLinkFile = "C:\Users\Ubirajara\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\_pext1\B¡blia Sagrada\B¡blia Sagrada.exe.lnk" 
Set oLink = oWS.CreateShortcut(sLinkFile) 
oLink.TargetPath = "D:\_pext1\B¡blia Sagrada\B¡blia Sagrada.exe" 
oLink.Save 

The issue? The shortcut isn't created because it does not recognize "sLinkFile = "C:\Users\Ubirajara\AppData\Roaming\Microsoft\Windows\Start Menu\Programs_pext1\B¡blia Sagrada\B¡blia Sagrada.exe.lnk"".

It doesn't happen if I don't use diacritics, but really I have a lot of folders and files with that signals...

How to correct it to allow correct writing on .vbs file?

PS2:

I tried following commands, alone and together, with no success:

cmd /u

chcp 860

chcp 1200

mode con cp select=860

mode con cp select=1200

Also I tried it with cmd raster font and with other available fonts...

share|improve this question

1 Answer 1

Notepad is opening your file with the wrong encoding. Try opening using the Open dialog box, and in the bottom selecting other encodings:

Encoding selection

Note that Microsoft uses non-standard names for the encodings. "Unicode" is actually UTF-16LE, and "Unicode big endian" is actually UTF-16BE.

share|improve this answer
    
See my edit :) the issue is worse I written... –  kokbira Aug 22 '12 at 22:44
    
Opening as you suggested also do not solve the "display issue". On ANSI, the same issue occurs; on Unicode and Unicode big endian, no alphabet characters are shown; on UTF-8, it replaces ¡ with , but not with í... I.e., correct encoding "may be lost" :( –  kokbira Aug 23 '12 at 13:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.