- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
A registry (.reg) file looks a little removed from a regular text, no doubt a lot to do with us of unicode, but also other strange bytes. Is there a bit of Fortran code which will write a .reg file in the required format?
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
You're writing with formatted output, which will always add a line terminator (CR-LF) at the end of each record. Using ADVANCE='NO' doesn't stop this. The only way to avoid getting the terminators is to use unformatted, stream output.
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
You can write all ask plain text, binary records have a type deliminator and then comma separated hex values. A simple reg file write could be 10 lines of code. Look at the wiki page.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Ok, I've written a .reg file which writes an identical file to the one that is exported from regedit, with exception of an extra 0D0A at the end of the file. I tried ADVANCE=NO in the format statement, but it still writes these extra 2 bytes.
Any idea how to suppress them?
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Use ACCESS='STREAM' and FORM='UNFORMATTED' to write direct binary.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I tried access='stream' and form='unformatted' but I still get the stray 0d 0a at the end of the file.
Reg files attached (renamed as .txt)
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Both files have CR LF (0D00 0A00) twice at the end in double byte character format (Bigendian) but in the one you write an additional CRLF (0D0A) is output in single byte format at the end. However I an not trusting anything I see in a text editor I would want to read type bytes as a stream byte by byte and check that.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Yes, the file I write has an extra od oa at the end (which I don't write). The regedit exported one doesn't.
I look at them in https://hexed.it/
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Well I am not sure what is happening here. When I write a text file from Fortran I get an ANSI/UTF-8 file with single byte characters. Your file is double byte encoded and then has a EOF in single byte format. But the Fortran runtime as I see it only supports ANSI for formatted (text) files. Do you gave an example code a few lines showing the open, write and close so we can test/replicate? Someone else may be able to see the problem but I think I would need to plod through step by step through what you are doing.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Here is the code, with the middle portion stripped out, but you can get the idea:
open(unit=2,file='aqreg.reg',status='unknown')
write(2,'(a)',advance='no') &
char(z'ff')//char(z'fe')//char(z'57')//char(z'00')//char(z'69')//char(z'00')//char(z'6e')//char(z'00')//char(z'64')//char(z'00')//char(z'6f')//char(z'00')//char(z'77')//char(z'00')//char(z'73')//char(z'00')//&
char(z'0d')//char(z'00')//char(z'0a')//char(z'00')//char(z'0d')//char(z'00')//char(z'0a')//char(z'00')
close(unit=2)
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
You're writing with formatted output, which will always add a line terminator (CR-LF) at the end of each record. Using ADVANCE='NO' doesn't stop this. The only way to avoid getting the terminators is to use unformatted, stream output.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I still get the 0d 0a:
open(unit=2,file='aqcomp.inc',status='unknown',access='stream',form='unformatted')
write(2) ecstring
close(unit=2)
ecstring is of length 55
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
The most recent file is not remotely something that the registry editor would accept for an import.
I cannot reproduce the extra CR-LF using a recent compilers.
(Use of a hardcoded unit number below 10 makes me nervous - prefer a value obtained using the NEWUNIT specifier, but that does not appear to be the issue here.)
The registry editor will import "ansi" encoded files (as would be written by normal/boring Fortran formatted write statements), so none of this should be necessary. When checking the results of an import, be mindful of registry redirection - are you looking in the right place?
(From a Fortran language point of view, the easiest way to write UTF-16LE encoded files is via an appropriate ENCODING specifier in the OPEN statement. But Fortran processor support for different encodings is processor dependent, and the Intel Fortran runtime does not support UTF-16LE encoding.)
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Yes I know this is not a registry file, I was just experimenting with dummy code. I did run your code and I did not get the trailing 0d 0a, so it must be something in my code or compilation options. Thanks for helping out.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
When I export a .reg file I get a text file (on my system it is encoded UCS2 LE BOM but ANSI should be OK) with CRLF at the end of every line. Attach your 2 reg files you are comparing.
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora