This is a fix for the direct to font DBCS cursor.

If we're sitting on a DBCS lead byte it extends the cursor to two
characters rather then just one.
UTF-8 processing update

1) Removed the locking of terminal in UTF-8 mode on font selection.
2) The alt_utf flag is removed
3) The saved_utf flag is removed.
4) On terminal reset the utf flag is set to:
	(term->ucsdata->line_codepage==CP_UTF8)
5) All ISO-2022 controls (except ESC % @) are properly ignored in utf-8 mode.

6) Added rxvt compatible UTF-8 mode for ISO-2022 and UTF-8 at the same time.

Also added.
7) Under Debian/Ubuntu my locale is en_GB.utf8, not *UTF-8*.
8) Some UTF-8 locales don't have a utf8 suffix eg: en_AG, en_IN, en_NG
9) Stop the BMP repeating for 16bit UCS fonts (Win32 & X11, not Pango)
10) High bit characters for title an icon are translated to utf-8.
11) CSI Pn SP Z used for character width override.
12) CSI Pn SP D used for current codepage changing.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Reasoning for UTF-8 change ...

No version of curses understands ISO-2022 (outside Japan) but some do
understand UTF-8. The Japaneese version of ISO-2022 is more complex.

The utf flag is not controlled by most host software, only specialist
software (and scripts) that understand ISO-2022 and UTF-8 will use
it. Therefor the existance of multi copies of the flag (alt & saved)
is not useful and has caused confusion.

This is because the UTF-8 functionality of most host software is
controlled through the 'locale' functions. These have no built in
facilities for sending initilisation sequences to a terminal to change
it's mode. However, a host script can change the locale and so should
be able to change the terminal to match.

    if [ "`locale charmap 2>/dev/null`" = "UTF-8" ]
    then echo -ne '\033%G'		# DOCS UTF-8
    else echo -ne '\033%@'		# DOCS RETURN
    fi

Alternativly ...
    if [ "`locale charmap 2>/dev/null`" = "UTF-8" ]
    then echo -ne '\033[0;1400 D'	# UTF-8 without ISO-2022
    else echo -ne '\033[0;2022 D'	# Normal ECMA-35 (ISO-2022)
    fi

Most utf-8 software expects normal sequences to have no effect on a
UTF-8 terminal, ncurses for example may still send smacs strings even
when using UTF-8 line drawing characters.

For the future it's likely that the terminal will run mostly in UTF-8
so this mode will become even less useful.

=-=
The automatic locking of the utf flag for UTF-8 fonts is confusing in
that it means there are two distinct versions of PuTTY control sequences
(with or without ISO-2022) without an obvious configuration warning. In
addition for current versions of PuTTY the functionality is provided by
the option to disable remote control of character sets.

=-=
When the 'DOCS return' sequence is used the ISO-2022 engine must be
returned to exactly the state it was in when the original 'DOCS' was
received. (ECMA-035)

=-=
The rxvt compatibility (wishlist/utf8-plus-vt100) means that all the
ISO-2022 sequences can be made to continue to work while in UTF-8
mode. This is only reasonable when you have a hellspawn host that has
an unlabeled mixture of unicode and non-unicode applications and data
but it can still be useful.  (eg: if parts of your filesystem have been
around for nearly 20 years like mine) Even then there are reasonable
arguments that this should be done by translation applications not an
emulator.

This mixed mode also means that the UTF-8 decoder had to be changed;
instead of mostly using an FSM with a single character lookahead buffer
the UTF-8 decoder has been changed to use only a lookahead buffer.
This buffer is also used instead of the tiny FSM for the printer output
and is likely to be a good solution for full ISO-2022.

The unmixed mode is still the default. Note: As the escape sequence to
get into the mixed mode is NOT an ISO-2022 sequence the rules about DOCS
restoring the ISO-2022 state do not apply.

=-=
ECMA-48: 8.3.90 PEC - PRESENTATION EXPAND OR CONTRACT

CSI Pn SP Z used for character width override. Only applies to UTF-8
		characters that are not in US-ASCII.
	Pn=0   Default
	Pn=1   Force Wide for unicode chars.
	Pn=2   Force narrow for unicode chars.
	Pn=5   Force one Wide unicode char.
	Pn=6   Force one narrow unicode char.

ECMA-48: 8.3.53 FNT - FONT SELECTION

CSI Pf ; Pc; SP D
	Change current codepage.
	Pf must be zero or default.
	Pc is a supported codepage number

	2022        Switch to ISO 2022 mode.
	65001       UTF-8 in normal DOCS mode.
	4110        UTF-8 randomly mixed with ISO 2022.
	1400        UTF-8 with ISO-2022, ECMA-35 and DOCS RETURN disabled.

ESC % G   DOCS UTF-8
	Switch to UTF-8 all ISO-2022 sequences except ESC % @ are disabled.
ESC % @	  DOCS RETURN
	Switch back to iso 2022 mode.
Add a config switch to control the new UTF-8 modes.

Option sets the value of the term->utf field on reset.

The configuration values are
    0 => off
	    Terminal uses the configured codepage after a reset.
    1 => on
	    Terminal uses UTF-8 after a reset, DOCS RETURN is used to get to
	    the configured codepage.
    2 => mixed
	    Terminal uses UTF-8 after a reset. But if the character sequence
	    isn't legal UTF-8 it will be treated as the configured codepage.
    3 => locked
	    This isn't in the configuration, but if added it'll be UTF-8
	    without DOCS RETURN enabled. The non-ISO-2022 switching sequence
	    CSI Pf ; Pc; SP D will still work.
Adding better support for some Chinese character sets

Adding better support for some 国家标准 character sets. (ie Chinese standard
character sets)

This does NOT need a specific font as long as the unicode system can find the
requsite characters.

Note the change in the defaults; it is now reccomended to explicitly
specify the line character set for DBCS systems.

Also added a few Windows charsets and moved UTF-8 right to the top of
the list.

Minor change to ldiscucs.c, for non-UTF16 machines the characters
for surrogate pairs have already been checked.
This patch adds ANSI.SYS, SCO Xenix 2.3.2 and a general ANSI emulation.

The SCO Xenix is a well defined but rather old style emulation similar
in many respects to the ANSI.SYS emulation but a bit nicer. The later
SCO Unix variants are far more uncertain as they cover may versions of
SCO Unix where the emulation was changed to maintain or provide minimal
compatibility with other systems.

In the SCO Xenix emulation I have assumed the mapchan(1) facility has
been used to set the default character set to the putty line codepage. So
if your application assumes the mapchan process hasn't been run you will
need to set the line charset to CP437. The ANSI.SYS emulation forces CP437.

echo -e '\e[4040"p'   # Set normal PuTTY (xterm) mode.
echo -e '\e[4041"p'   # Set modern Ansi mode, all available non VT sequences.
echo -e '\e[4042"p'   # Set ANSI.SYS emulation
echo -e '\e[4043"p'   # Set SCO Xenix

echo -e '\e[4030"p'   # Set pure VT52 mode
echo -e '\e[4031"p'   # Set pure VT220+ mode

These and all the compatibility stuff can be turned off using the compile
option DISABLE_COMPAT. Note, CSI 4030"p turns off _nearly_ all the CSI
sequences, the exception being ones that begin "ESC [ 404".
The SCO emulation overrides the configured function key definitions.

The SCO Xenix emulation does not have the reverse or graphic attribute
variables. However, I do have full details if these are needed.

Attributes DIM and CONCEAL have been added. Concealed text is shown by
highlighting it with the mouse.

Altered CSI 21m to be dup of CSI 22m; I didn't know about this convention
when I chose to use single underline as a near enough equlivent to
double underline.

The SCO ACS character set on unix has been fixed; added the OEM glyphs
for characters 1..31.
The default SCO mapping for the number pad '5' key has been fixed.
The ECMA-48 'REP' code, repeat character has been added.
I've added SCO's new CSI 13m mode and the CSI=g code.
Removed the supposedly SCO CSI 6m.
Linux CSI 8 ] for default colours. CSI 8 ; 1 ] to reset.
Added CSI 8 ; 2 ] to reconfigure the default colours and the BLINK
attribute to blink any other attribute.

In ANSI.SYS mode CSI-J homes cursor.

Added XTerm's vttest modes; CSI ?40 l/h & CSI ?45 l/h
    This means DECCOLM is disabled by default and stops xterm's "tput init"
    clearing the screen.

Default blink now to DIM not blank, set with:
   echo -e '\e[0;2m\e[8;2]\e[m'
Set back to PC Style with:
   echo -e '\e[0;8m\e[8;2]\e[m'

I haven't added GUI configs for any of this; don't know which you'd prefer.
    Possibilities:
	Terminal Type: xterm/ansi/ansisys/scoansi/vt220/vt52
	Blink attribute: Dim/Conceal/Reverse ...

I've had to move the literal character display into it's own function
so I can call it from multiple places.

Readded Linux DTF range (U+F000 -> CP437) explicitly into the emulation.
This means I no longer need the "happy coincidence" of the OEMCP being
mapped to U+F000.

Cleaned out "vt52_bold" variable; it does nothing.
Reconfigure PuTTY colour scheme from Unix host.

This is possibly related to: /wishlist/colour-scheme.html

These colour schemes are not stored in the PuTTY session file and so
have to be dynamically configured from the host.

The script can read the colour scheme from a Windows PuTTY registry
dump or a Unix session file.