mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_fwrite): use rb_w32_write_console under Windows.
* win32/win32.c (rb_w32_write_console): added to write to write Unicode using WriteConsoleW for stdout/stderr. [ruby-core:33166] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1342c3ba27
commit
ac0f5a53b6
3 changed files with 34 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sun Nov 28 04:40:00 2010 Luis Lavena <luislavena@gmail.com>
|
||||||
|
|
||||||
|
* io.c (io_fwrite): use rb_w32_write_console under Windows.
|
||||||
|
|
||||||
|
* win32/win32.c (rb_w32_write_console): added to write to write
|
||||||
|
Unicode using WriteConsoleW for stdout/stderr. [ruby-core:33166]
|
||||||
|
|
||||||
Sun Nov 28 03:58:47 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Sun Nov 28 03:58:47 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/http.rb: improve rdoc.
|
* lib/net/http.rb: improve rdoc.
|
||||||
|
|
4
io.c
4
io.c
|
@ -961,6 +961,10 @@ do_writeconv(VALUE str, rb_io_t *fptr)
|
||||||
static long
|
static long
|
||||||
io_fwrite(VALUE str, rb_io_t *fptr, int nosync)
|
io_fwrite(VALUE str, rb_io_t *fptr, int nosync)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
long len = rb_w32_write_console(str, fptr->fd);
|
||||||
|
if (len > 0) return len;
|
||||||
|
#endif
|
||||||
str = do_writeconv(str, fptr);
|
str = do_writeconv(str, fptr);
|
||||||
return io_binwrite(str, RSTRING_PTR(str), RSTRING_LEN(str),
|
return io_binwrite(str, RSTRING_PTR(str), RSTRING_LEN(str),
|
||||||
fptr, nosync);
|
fptr, nosync);
|
||||||
|
|
|
@ -5286,6 +5286,29 @@ rb_w32_write(int fd, const void *buf, size_t size)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
rb_w32_write_console(VALUE str, int fd)
|
||||||
|
{
|
||||||
|
static int disable;
|
||||||
|
HANDLE handle;
|
||||||
|
DWORD dwMode, reslen;
|
||||||
|
|
||||||
|
if (disable) return -1L;
|
||||||
|
handle = (HANDLE)_osfhnd(fd);
|
||||||
|
if (!GetConsoleMode(handle, &dwMode) ||
|
||||||
|
!rb_econv_has_convpath_p(rb_enc_name(rb_enc_get(str)), "UTF-16LE"))
|
||||||
|
return -1L;
|
||||||
|
|
||||||
|
str = rb_str_encode(str, rb_enc_from_encoding(rb_enc_find("UTF-16LE")), 0,
|
||||||
|
Qnil);
|
||||||
|
if (!WriteConsoleW(handle, (LPWSTR)RSTRING_PTR(str), RSTRING_LEN(str)/2, &reslen, NULL)) {
|
||||||
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||||
|
disable = TRUE;
|
||||||
|
return -1L;
|
||||||
|
}
|
||||||
|
return (long)reslen;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unixtime_to_filetime(time_t time, FILETIME *ft)
|
unixtime_to_filetime(time_t time, FILETIME *ft)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue