News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MasmBasic Store

Started by clamicun, August 14, 2017, 07:26:01 PM

Previous topic - Next topic

clamicun

jj good morning,
I don't want to step on your nervs, but again a question on MasmBasic.

If I use Store offset store_file,Files$() the file reads in a texteditor like e.g. this:

E:\$RECYCLE.BIN\S-1-5-21-191576419-2953248153-4053527571-1000
E:\DevCpp
E:\DevCpp\bin
E:\DevCpp\Examples
E:\FASM_WIN32\Work\WinTest

But if I open it with a hexeditor it starts always with:

0EFh 0BBh 0BFh
What is this good for ?

jj2007

Hi Clamicun,

It's the UTF8 BOM that ensures that Notepad & friends can read the text properly. GetFiles *.txt returns the Files$() array in UTF-8 format, so that it can be used everywhere in the World ;)

If you don't want to use this feature, put GfNoUtf8=1 before Store (yep, this is an undocumented switch, sorry :icon_redface:):

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  GetFiles *.as?|*.rc
  SortFiles                     ; recent files on top

  GfNoUtf8=1
  Store "Asm_rc_Plain.txt", Files$()

EndOfCode


I attach a full example, including a file with a name that will not show up in some editors with GfNoUtf8=1. You can see the difference (at least on Win7-64) with these two lines used at the bottom of the attached example:

   Launch ExpandEnv$("%ProgramFiles%\Windows NT\Accessories\wordpad.exe Asm_rc_Utf8.txt")
   Launch ExpandEnv$("%ProgramFiles%\Windows NT\Accessories\wordpad.exe Asm_rc_Plain.txt")

Note that in contrast to Wordpad and browsers, Notepad.exe apparently has some autodetect mechanism, it displays the filename correctly for both versions.

P.S.: You certainly don't step on my nerves, this is very useful feedback :icon14:

mineiro

bonjour clamicun;
If you open notepad and save that document without press any key on keyboard as utf8 you will see that the file don't have 0 bytes, the same to unicode.
Sounds to me that notepad need a hint to tell text editor what type of encode is being used. That bytes are called BOM. Not all text editors use BOM, but on notepad this is truth.

If you try to echo on console mode an utf8 text you can see garbage on screen but that don't means that that don't work. So, if you redirect console mode string to text file you need insert (write) first BOM and after append text need to check output by using notepad. This was the way that I find to check if utf8 works on console mode. I concluded that works but we don't have fonts to see that text on console mode, only on graphical way.
Not sure why Windows don't come with these fonts.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything