Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
27c8dfdd
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
27c8dfdd
编写于
2月 03, 2019
作者:
A
Austin Bonander
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve error message and docs for non-UTF-8 bytes in stdio on Windows
cc #23344
上级
4314dbaa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
1 deletion
+48
-1
src/libstd/io/stdio.rs
src/libstd/io/stdio.rs
+45
-0
src/libstd/sys/windows/stdio.rs
src/libstd/sys/windows/stdio.rs
+3
-1
未找到文件。
src/libstd/io/stdio.rs
浏览文件 @
27c8dfdd
...
...
@@ -131,6 +131,11 @@ fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> {
///
/// [`io::stdin`]: fn.stdin.html
/// [`BufRead`]: trait.BufRead.html
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return
/// an error.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
Stdin
{
inner
:
Arc
<
Mutex
<
BufReader
<
Maybe
<
StdinRaw
>>>>
,
...
...
@@ -144,6 +149,11 @@ pub struct Stdin {
/// [`Read`]: trait.Read.html
/// [`BufRead`]: trait.BufRead.html
/// [`Stdin::lock`]: struct.Stdin.html#method.lock
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return
/// an error.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
StdinLock
<
'a
>
{
inner
:
MutexGuard
<
'a
,
BufReader
<
Maybe
<
StdinRaw
>>>
,
...
...
@@ -157,6 +167,11 @@ pub struct StdinLock<'a> {
///
/// [lock]: struct.Stdin.html#method.lock
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return
/// an error.
///
/// # Examples
///
/// Using implicit synchronization:
...
...
@@ -328,6 +343,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
///
/// Created by the [`io::stdout`] method.
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
/// an error.
///
/// [`lock`]: #method.lock
/// [`io::stdout`]: fn.stdout.html
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -343,6 +363,11 @@ pub struct Stdout {
/// This handle implements the [`Write`] trait, and is constructed via
/// the [`Stdout::lock`] method.
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
/// an error.
///
/// [`Write`]: trait.Write.html
/// [`Stdout::lock`]: struct.Stdout.html#method.lock
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -358,6 +383,11 @@ pub struct StdoutLock<'a> {
///
/// [Stdout::lock]: struct.Stdout.html#method.lock
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
/// an error.
///
/// # Examples
///
/// Using implicit synchronization:
...
...
@@ -476,6 +506,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
/// For more information, see the [`io::stderr`] method.
///
/// [`io::stderr`]: fn.stderr.html
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
/// an error.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
Stderr
{
inner
:
Arc
<
ReentrantMutex
<
RefCell
<
Maybe
<
StderrRaw
>>>>
,
...
...
@@ -487,6 +522,11 @@ pub struct Stderr {
/// the [`Stderr::lock`] method.
///
/// [`Stderr::lock`]: struct.Stderr.html#method.lock
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
/// an error.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
StderrLock
<
'a
>
{
inner
:
ReentrantMutexGuard
<
'a
,
RefCell
<
Maybe
<
StderrRaw
>>>
,
...
...
@@ -496,6 +536,11 @@ pub struct StderrLock<'a> {
///
/// This handle is not buffered.
///
/// ### Note: Windows Portability Consideration
/// When operating in a console, the Windows implementation of this stream does not support
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
/// an error.
///
/// # Examples
///
/// Using implicit synchronization:
...
...
src/libstd/sys/windows/stdio.rs
浏览文件 @
27c8dfdd
...
...
@@ -188,7 +188,9 @@ pub fn handle(&self) -> c::HANDLE {
}
fn
invalid_encoding
()
->
io
::
Error
{
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidData
,
"text was not valid unicode"
)
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidData
,
"Windows stdio in console mode does not support non-UTF-8 byte sequences;
\
see https://github.com/rust-lang/rust/issues/23344"
)
}
fn
readconsole_input_control
(
wakeup_mask
:
c
::
ULONG
)
->
c
::
CONSOLE_READCONSOLE_CONTROL
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录