Before Tera Term 5, the character set of the internal buffer was DBCS (Double byte Character Set). For example, when "Language" is set to "Japanese", character coding in internal buffer was Shift_JIS.
The character encoding of Tera Term 5 internal buffer is Unicode.
The data flow is as follows.
                                                                              +--------------+
                              +------------------------+ Code:Unicode         |              |
                              |                        +--------------------->+  Window      |
                              |  buffer@buffer.c       |                      |   Display    |
                              |   Code:Unicode         | Code:Unicode         |   Print      |
                              |                        |  BuffPutUnicode()    |              |                                         +----------+
                              |                        +<------------------+  +--------------+          +-----------------------+      |          |
                              +------------------------+                   |                            |                       |      |Log File  |
                                                                           +----------------------------+ VTParse()@vtterm.c    +----->+          |
                              +------------------------+ CommRead1Byte()                                |  Terminal             |      |          |
                              |                        +----------------------------------------------->+                       |      +----------+
                              |  Input buffer@ttpcmn   |                                                |                       |
+-----------+                 |   Code:Input           | Code:                                          +----+------------------+
|           |                 |                        |  Unicode to Input    +--------------+               |
|  Socket   +---------------->+                        +<---------------------+              |               |
|  Serial   |  CommReceive()  +------------------------+  CommTextEchoW()     |  Talker      |               |
|  Pipe     |                                             CommBinaryEcho()    |   Keyboard   |               | Code:Unicode(UTF-8)
|  Plugin   |                 +------------------------+                      |   SendMem    |               |  DDEPut1()
|           +<----------------+                        | Code:                |    File      |               |
+-----------+  CommSend()     |  Output buffer@ttpcmn  |  Unicode to Output   |    Clipboard |               |
                              |   Code:Output          +<---------------------+    macro     +<---------+    |
                              |                        |  CommTextOutW()      |              |          |    |
                              |                        |  CommBinaryOut()     +--------------+          |    |
                              +------------------------+  CommRawOut()                                  |    |
                                                                                                        |    |
                                                                                                        |    |
                                                                                                        |    |
                                                                                                        |    v
                                           +-------------------+      DDE, UTF-8/binary               +-+----+-----------+
                                           |                   +------------------------------------->+                  |
                                           |  ttpmacro.exe     |                                      |  ttdde.c         |
                                           |                   |                                      |                  |
                                           |                   |      DDE, UTF-8                      |                  |
                                           |                   +<-------------------------------------+                  |
                                           +-------------------+                                      +------------------+
On Windows 95/98/Me, key input is converted to Unicode before processing. When drawing, characters are converted from Unicode to MBCS.