Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
bingbingbingbing
mono
提交
7c23f96f
M
mono
项目概览
bingbingbingbing
/
mono
与 Fork 源项目一致
从无法访问的项目Fork
通知
35
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mono
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c23f96f
编写于
3月 09, 2011
作者:
A
Atsushi Eno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto detect BOM-less utf-16 and utf-32. Fixed bug #674580.
上级
707b30ed
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
3 deletion
+27
-3
mcs/class/System.XML/System.Xml/XmlInputStream.cs
mcs/class/System.XML/System.Xml/XmlInputStream.cs
+19
-3
mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
+8
-0
未找到文件。
mcs/class/System.XML/System.Xml/XmlInputStream.cs
浏览文件 @
7c23f96f
...
...
@@ -339,11 +339,13 @@ namespace System.Xml
class
XmlInputStream
:
Stream
{
public
static
readonly
Encoding
StrictUTF8
;
internal
static
readonly
Encoding
StrictUTF8
,
Strict1234UTF32
,
StrictBigEndianUTF16
;
static
XmlInputStream
()
{
StrictUTF8
=
new
UTF8Encoding
(
false
,
true
);
Strict1234UTF32
=
new
UTF32Encoding
(
true
,
false
,
true
);
StrictBigEndianUTF16
=
new
UnicodeEncoding
(
true
,
false
,
true
);
}
Encoding
enc
;
...
...
@@ -422,9 +424,23 @@ namespace System.Xml
buffer
[--
bufPos
]
=
0xEF
;
}
break
;
case
0
:
// It could still be 1234/2143/3412 variants of UTF32, but only 1234 version is available on .NET.
c
=
ReadByteSpecial
();
if
(
c
==
0
)
enc
=
Strict1234UTF32
;
else
enc
=
StrictBigEndianUTF16
;
break
;
case
'<'
:
// try to get encoding name from XMLDecl.
if
(
bufLength
>=
5
&&
GetStringFromBytes
(
1
,
4
)
==
"?xml"
)
{
c
=
ReadByteSpecial
();
if
(
c
==
0
)
{
if
(
ReadByteSpecial
()
==
0
)
enc
=
Encoding
.
UTF32
;
// little endian UTF32
else
enc
=
Encoding
.
Unicode
;
// little endian UTF16
}
else
if
(
bufLength
>=
4
&&
GetStringFromBytes
(
1
,
4
)
==
"?xml"
)
{
// try to get encoding name from XMLDecl.
bufPos
+=
4
;
c
=
SkipWhitespace
();
...
...
mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
浏览文件 @
7c23f96f
...
...
@@ -1374,5 +1374,13 @@ namespace MonoTests.System.Xml
}
while
(
read
>
0
);
Assert
.
AreEqual
(
"<child>a</child>"
,
sb
.
ToString
(),
"#1"
);
}
[
Test
]
public
void
BOMLessUTF16Detection
()
// bug #674580
{
var
ms
=
new
MemoryStream
(
Encoding
.
Unicode
.
GetBytes
(
"<root />"
));
var
xtr
=
new
XmlTextReader
(
ms
);
xtr
.
Read
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录