The accented-non-accented thing appears to me as a problem of the codepage more than a thinbasic problem
we will find out,
open windows explorer, where you can type the path, type %COMSPEC% [enter]
the windows console will open,into console window type CHCP[enter]
you will be informed about the currently used codepage, ANSI i guess 850 or 1252 (latin or western europe) if french speaking
Now thinbasic default works unicode-aware using UTF8 which is a codepage number 65001
%CP_utf7 = 65000
%CP_utf8= 65001
%CP_utf16_LE = 1200 ' this is the WIDECHAR 16 bit on windows
%CP_utf16_BE = 1201 ' UNIX,Linux,Solarix,Androidix, Macintoshix,ComputerLäuftNix,..
ANSI/OEM/EBCDIC/BOCU/SCSU are a couple of codepage-collections mostly deprecated
When you are working with a visible console window, i.e. your code contains
then it were applicable to let
Console_SetoutputCP( %CP_UTF8 )
' Console_SetInputCP( %CP_UTF8 ) might set this to the number <XXX>
Console_ShowWindow( %Console_SW_SHOWNORMAL )
and it should go conform with content of thuinbasic UTF8-encoded strings.
When no visible console window either you use
string FileToRun = App_Scriptpath & "myBatchfile.bat"
string FileResult= App_Scriptpath & "reply.txt"
String myBatchfile ="@echo off" & $CRLF & "chcp >" & FileResult & $crlf & $spc
File_Save(FileToRun, myBatchfile)
Shell FileToRun, "", True
msgbox "Returned was " & File_load(FileResult)
' .bat-scripts are usually ANSI. if your batchfile contains accented chars or the result is unreadable convert
myBatchfile=utf8ToAnsi$(myBatchfile)
before saving it and vice versa
msgbox "Returned was " & AnsiToUtf8$(File_load(FileResult))
Shell_CaptureOutput can do this without the files on a more direct way since thinbasic takes care of incoming data to be UTF8 (at least i hope so)
Begin Const
$_CMD= "%COMSPEC% /C "
End Const
string sAll = Shell_captureOutput( $_CMD & "Dir /a:-d /b" ,"", %SW_HIDE, 20)
string sCurrDir = Shell_CaptureOutput( $_CMD & "CD", "",%SW_HIDE,10)
msgbox "Found Files" & $crlf & sAll, %mb_iconInformation, sCurrDir
String sFile()
Long numFiles = parse sAll, sFile, $CRLF
' will make an array of all files in sAll
string isTB = Shell_CaptureOutput( $_CMD & "IF EXIST " & $DQ & App_Path & "thinbasic.exe" & $DQ & " (ECHO TRUE) ELSE (ECHO FALSE)", "", %SW_HIDE,10)
msgbox App_Path & "thinbasic.exe EXIST = " & isTB
'The parenthesis surrounding ECHO TRUE and ECHO FALSE prevent from additional whitespace that might follow after "FALSE" so it will not return is as "FALSE "
' For directories the path must end with backslash when EXIST is used
gives you an idea.
Of course you can combine batchfiles and result-files with the direct-method , just for a reminder
Echo Hello>myFile.txt
Echo World >>myFile.txt
the single "arrow >" ovewrites the content of an existing file
and double "arrow >>" appends it to the existing content.
Not a programmatic solution were to lauch cmd,
click on the icon(system-menu) upper left corner and
check settings,
then the rightmost tab should also tell the current by the system used codepage that i would try as number <XXX> mentioned above
Bookmarks