[Wine] Correct wrong character set?

Martin Gregorie martin at gregorie.org
Sat Apr 17 04:02:11 CDT 2010


On Fri, 2010-04-16 at 20:39 -0500, cnbiz850 wrote:
> Maybe I should put it this way.  The script I edit is a formated
> language (like C).  Before it can be executed, the Windows program -
> by using its provided editor - somehow processes/compiles it into its
> needed proprietary file format.
>
So your editor is more than just an editor: it is a compiler as well and
saves both the ASCII text file and the compiler output.

> I think at the time of the processing/compiling, it checks the ASCII
> text I put in and verifies that it is in the legal format.  So that is
> when it complains about the CRLF related problem.
> 
Or more likely, it doesn't recognise the LF as a newline.

> Through our discussion here, I take it that because I run the Windows
> program through Wine, the newline character I type in is a LF rather
> than the required CRLF, then the program complains about it.
>
Not exactly. The keyboard emits a scan code which MS operating systems
keyboard drivers pass to the program as CR and the Linux keyboard driver
passes as LF. Most DOS/Windows programs won't recognise LF as a newline,
but often treat it as an ordinary non-printing character. If you're
using C a further library function ensures that this always matches '\n'
on input and that on output '\n' becomes CRLF or LF. Other languages
will do something similar.

Its actually quite a mess on the MS side, with newline being CR from the
keyboard but CRLF when read from a file and always being written as
CRLF.

>   Guess I am more and more inclined that Wine should take the
> responsibility in putting in the right newline character.  
> 
I'd expect that Wine would handle the conversion of keystrokes but would
pass files unchanged. Anything else would cause major problems. Think of
the effects if it converted LF to CRLF in an exe or other binary file.
IOW it would have to be able to distinguish text files from other file
types with 100% accuracy which would be nearly impossible.
 
I'd suggest that your best bet is a simple script like this:

	#!/bin/sh
	dos2unix $1
	gedit $1	# Substitute your favourite Linux editor here
	unix2dos $1

The double conversion is a good idea because some Linux editors don't
treat CRLF as a simple newline. BTW, you can run a file through unix2dos
more than once without damaging it.

Another thought: have you looked for a Linux equivalent to your
editor/compiler? There may be one. For example, the Parallax STAMP
program editor does pretty much what you're describing: it holds program
source as a DOS text file but downloads a tokenised form into the STAMP
to be run. There is an equivalent Linux development package consisting
of a tokeniser and a downloader/debugger. I haven't used it, but I
imagine that it uses standard Linux text editors to write programs.


Martin





More information about the wine-users mailing list