Tcl Source Code

Check-in [b4ff1c850f]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add code to set the encoding for the console.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-1-branch-old
Files: files | file ages | folders
SHA1: b4ff1c850ff28ed4dc309ee37bd913174e518f7e
User & Date: redman 1999-03-13 02:55:56
Context
1999-03-13
03:09
The tclLibraryPath was being composed of mixed native and UTF strings. Now it is composed of potent... check-in: 1efc651293 user: surles tags: core-8-1-branch-old
02:55
Add code to set the encoding for the console. check-in: b4ff1c850f user: redman tags: core-8-1-branch-old
1999-03-12
23:47
modified the Tcl_SetDefaultEncodingDir routine to use its own memory when caching the tclDefaultEnco... check-in: d8e6c3b83e user: surles tags: core-8-1-branch-old
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to win/tclWinConsole.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
....
1125
1126
1127
1128
1129
1130
1131

1132
1133
1134
1135
1136
1137
1138
....
1141
1142
1143
1144
1145
1146
1147


1148
1149
1150
1151
1152
1153
1154
....
1175
1176
1177
1178
1179
1180
1181

1182
1183
1184
 *	and the "console" channel driver.
 *
 * Copyright (c) 1999 by Scriptics Corp.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinConsole.c,v 1.1.2.1 1999/02/26 02:19:23 redman Exp $
 */

#include "tclWinInt.h"

#include <dos.h>
#include <fcntl.h>
#include <io.h>
................................................................................
    }
    if (consolePtr->writeBuf != NULL) {
	ckfree(consolePtr->writeBuf);
	consolePtr->writeBuf = 0;
    }
    ckfree((char*) consolePtr);

    if (errorCode == 0) {
        return result;
    }
    return errorCode;
}
 
/*
 *----------------------------------------------------------------------
 *
 * ConsoleInputProc --
................................................................................

Tcl_Channel
TclWinOpenConsoleChannel(handle, channelName, permissions)
    HANDLE handle;
    char *channelName;
    int permissions;
{

    ConsoleInfo *infoPtr;
    ThreadSpecificData *tsdPtr;
    DWORD id;

    tsdPtr = ConsoleInit();

    /*
................................................................................
    
    infoPtr = (ConsoleInfo *) ckalloc((unsigned) sizeof(ConsoleInfo));
    memset(infoPtr, 0, sizeof(ConsoleInfo));

    infoPtr->validMask = permissions;
    infoPtr->handle = handle;



    /*
     * Use the pointer for the name of the result channel.
     * This keeps the channel names unique, since some may share
     * handles (stdin/stdout/stderr for instance).
     */

    wsprintfA(channelName, "file%lx", (int) infoPtr);
................................................................................
    /*
     * Files have default translation of AUTO and ^Z eof char, which
     * means that a ^Z will be accepted as EOF when reading.
     */
    
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-translation", "auto");
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-eofchar", "\032 {}");


    return infoPtr->channel;
}






|







 







<
<
<







 







>







 







>
>







 







>



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
507
508
509
510
511
512
513



514
515
516
517
518
519
520
....
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
....
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
....
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
 *	and the "console" channel driver.
 *
 * Copyright (c) 1999 by Scriptics Corp.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinConsole.c,v 1.1.2.2 1999/03/13 02:55:56 redman Exp $
 */

#include "tclWinInt.h"

#include <dos.h>
#include <fcntl.h>
#include <io.h>
................................................................................
    }
    if (consolePtr->writeBuf != NULL) {
	ckfree(consolePtr->writeBuf);
	consolePtr->writeBuf = 0;
    }
    ckfree((char*) consolePtr);




    return errorCode;
}
 
/*
 *----------------------------------------------------------------------
 *
 * ConsoleInputProc --
................................................................................

Tcl_Channel
TclWinOpenConsoleChannel(handle, channelName, permissions)
    HANDLE handle;
    char *channelName;
    int permissions;
{
    char encoding[4 + TCL_INTEGER_SPACE];
    ConsoleInfo *infoPtr;
    ThreadSpecificData *tsdPtr;
    DWORD id;

    tsdPtr = ConsoleInit();

    /*
................................................................................
    
    infoPtr = (ConsoleInfo *) ckalloc((unsigned) sizeof(ConsoleInfo));
    memset(infoPtr, 0, sizeof(ConsoleInfo));

    infoPtr->validMask = permissions;
    infoPtr->handle = handle;

    wsprintfA(encoding, "cp%d", GetConsoleCP());
    
    /*
     * Use the pointer for the name of the result channel.
     * This keeps the channel names unique, since some may share
     * handles (stdin/stdout/stderr for instance).
     */

    wsprintfA(channelName, "file%lx", (int) infoPtr);
................................................................................
    /*
     * Files have default translation of AUTO and ^Z eof char, which
     * means that a ^Z will be accepted as EOF when reading.
     */
    
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-translation", "auto");
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-eofchar", "\032 {}");
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-encoding", encoding);

    return infoPtr->channel;
}