On 16/11/2012 16:15, Marcos Cruz wrote:
> the text is converted before "auto-typing" it. Isn't it? I mean
> non-ASCII characters.
>
Yes, in the simplest case it's just to map £ and © to the special codes
needed for SAM use, and to drop <CR> but convert <NL> to <CR>. Though I
also use the Win32 API to do a more thorough transliteration to the
closest ASCII equivalent (mostly stripping diacritics). I also added
manual transliteration of Cyrillic characters to attempt to preserve
comments in a batch of Russian BASIC listings.
For the other ports I was planning to use iconv to do the main
transliteration step. Under Linux iconv (part of libc-bin) appears to
include the support I'm after. Mac OS X is still using the traditional
libiconv, which gives strange results with the accents separated out
("coupé" -> "coup'e"). If I can't find a quick and easy solution for
that I'll just drop transliteration support. I'd rather spend my
SimCoupe development time on emulation, not text conversion!
> But I think automatic translation during spooling has some drawbacks:
> first, it would be useful only for non-ASCII characters (mainly, foreign
> language letters) provided by the SAM (mainly, by MasterBASIC) --or for
> all characters, in case the file is encoded in any ASCII-incompatible
> format, e.g. UTF-16, what is not common;
That uncertainty is the reason for only using the clipboard in Windows
-- I get the content in Unicode, so I don't need to guess the character
encoding. It appears SDL 2.0 (still under development) will be able to
provide the clipboard contents in UTF-8, which should give similar
results when combined with a working iconv.
> character translation done by the programmer in the source.
>
There will always be special cases, particularly for that kind of
private encoding scheme. I think it'd be best to require the user to
convert the text before spooling, with automatic translation disabled in
SimCoupe.
> Therefore, in my opinion, a simple and versatile option could be: first,
> assuming the spool file is encoded in an 8-bit ASCII-compatible charset
> (the actual encoding is irrelevant);
Assuming spooled text files are UTF-8 on non-Windows platforms might
give a similar success rate to assuming iso-8859-1 under Windows. I did
implement file spooling in the Windows version, but I felt the character
coding uncertainty would generate poor results and too many support
e-mails, so I took it out. It's tempting to do the same for non-Windows
platforms, but I might give it a chance.
> and second, feeding it "as is" to the SAM, without translation (of
> course beside end of line and maybe other control characters).
>
I'll probably add options for no translation, minimal translation, and
full transliteration. Hopefully even without that help the spooling
process will still make your life a bit easier :)
Si