Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Runtime
提交
9b4eece6
R
Runtime
项目概览
jobily
/
Runtime
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9b4eece6
编写于
1月 22, 2020
作者:
L
Levi Broderick
提交者:
GitHub
1月 22, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify char.IsControl and Rune.IsControl (#1988)
Not perf-critical, just some cleanup of low hanging fruit.
上级
9c82a36c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
13 deletion
+9
-13
src/libraries/System.Private.CoreLib/src/System/Char.cs
src/libraries/System.Private.CoreLib/src/System/Char.cs
+7
-11
src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs
src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs
+2
-2
未找到文件。
src/libraries/System.Private.CoreLib/src/System/Char.cs
浏览文件 @
9b4eece6
...
...
@@ -472,11 +472,10 @@ object IConvertible.ToType(Type type, IFormatProvider? provider)
public
static
bool
IsControl
(
char
c
)
{
if
(
IsLatin1
(
c
))
{
return
GetLatin1UnicodeCategory
(
c
)
==
UnicodeCategory
.
Control
;
}
return
CharUnicodeInfo
.
GetUnicodeCategory
(
c
)
==
UnicodeCategory
.
Control
;
// This works because 'c' can never be -1.
// See comments in Rune.IsControl for more information.
return
(((
uint
)
c
+
1
)
&
~
0x80u
)
<=
0x20u
;
}
public
static
bool
IsControl
(
string
s
,
int
index
)
...
...
@@ -487,12 +486,9 @@ public static bool IsControl(string s, int index)
{
throw
new
ArgumentOutOfRangeException
(
nameof
(
index
));
}
char
c
=
s
[
index
];
if
(
IsLatin1
(
c
))
{
return
GetLatin1UnicodeCategory
(
c
)
==
UnicodeCategory
.
Control
;
}
return
CharUnicodeInfo
.
GetUnicodeCategory
(
s
,
index
)
==
UnicodeCategory
.
Control
;
// Control chars are always in the BMP, so don't need to worry about surrogate handling.
return
IsControl
(
s
[
index
]);
}
public
static
bool
IsDigit
(
string
s
,
int
index
)
...
...
src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs
浏览文件 @
9b4eece6
...
...
@@ -1133,8 +1133,8 @@ public static bool IsControl(Rune value)
{
// Per the Unicode stability policy, the set of control characters
// is forever fixed at [ U+0000..U+001F ], [ U+007F..U+009F ]. No
// characters will ever be added to
the "control characters" group.
//
See http
://www.unicode.org/policies/stability_policy.html.
// characters will ever be added to
or removed from the "control characters"
//
group. See https
://www.unicode.org/policies/stability_policy.html.
// Logic below depends on Rune.Value never being -1 (since Rune is a validating type)
// 00..1F (+1) => 01..20 (&~80) => 01..20
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录