Dec 04, 2013, 8:38 AM
[FIXED] [2.5] Find a bug dealing with chinese character in Ext.net
I am a student from North China Electric Power University, and recently our team is developing a Management Information System .In our project we use Ext.net to display our front page. I think Ext.net is very convenient and Greatly improved the efficiency of our development.But now we have encountered such a problem there is some Chinese character that can not be recognized. Chinese character is replaced by "??". Just like the following picture .
this is a front page for test ,the code is simple.The code of File "Test.aspx" is:
The code of controllor File "Test.aspx.cs" is:
I will also show the config for my project ,even I think there is not so necessary.the web.config for my project is:
The left one I read inputStream by "new Byte[4096]",in this condition the result is that maybe a chinese character can be split to two character that can not recognized ,just like "??".And the right one works properly.
So I think there maybe a bug dealing with chinese character in Ext.net. When Ext.net dealing with the stream or a long string ,Ext.net maybe split a chinese character to two parts. For example ,"社" is "c9e7" in GBK Encoding,maybe we split it to "C9"and "E7" ,and then there is "??".
I am confused and this makes bad influence for my project.Please help me.
I will be very glad to receive your reply and expect you can help me solve this problem,thanks.
My Email is lushicheng@live.cn
this is a front page for test ,the code is simple.The code of File "Test.aspx" is:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="CuckooUnion.Website.Test" %>
<%@ Register TagPrefix="ext" Namespace="System.Resources" Assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" %>
<%@ Register TagPrefix="ext1" Namespace="Ext.Net" Assembly="Ext.Net, Version=2.3.1.41036, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87" %>
<!DOCTYPE html>
<html lang="zh">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>设备安装有限公司</title>
</head>
<body class="top_border">
<ext1:ResourceManager licenseKey="NTcwMjk3NjQsMiw5OTk5LTEyLTMx" runat="server" ID="MainResourceManager" InitScriptMode="Linked" ScriptMode="Debug" QuickTips="True" />
<div class="container container_all">
<div>
<style>
#sub_title {
border-top: #999999 1px solid;
line-height: 30px;
border-bottom: #999999 1px solid;
text-align: center;
width: 96%;
margin: 0 auto;
border-top: 1px solid #999;
border-bottom: 1px solid #999;
font-size: 12px;
font-family: 微软雅黑;
}
#title {
font-weight: bold;
font-size: 24px;
color: #000;
text-align: center;
}
</style>
<asp:Repeater runat="server" ID="RptNews">
<ItemTemplate>
<div style="width: 80%; margin: 0 auto; padding-top: 10px;">
<p style="font-family: 微软雅黑;font-size: 20px;font-weight: bold;text-align: center;">
<%#Eval("Title") %>
</p>
<div class="ez-box" style="height: 20px;">
</div>
<div id="sub_title">
文章来源:
<%#Eval("NewSource") %>
作者:
<%#Eval("Author") %>
发表时间:
<%#Eval("AuditDate") %>
点击量:
<%#Eval("Hits") %>
</div>
<div id="content" style="text-align: left;">
<%#Eval("Content") %>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</body>
</html>
We can find there is a "ext1:ResourceManager " in this file <ext1:ResourceManager licenseKey="NTcwMjk3NjQsMiw5OTk5LTEyLTMx" runat="server" ID="MainResourceManager" InitScriptMode="Linked" ScriptMode="Debug" QuickTips="True" />
But if I remove the "ext1:ResourceManager " from this page ,then all the chinese character in the file can be displayed right.The code of controllor File "Test.aspx.cs" is:
namespace CuckooUnion.Website
{
public class MeteDate
{
public string Title { get; set; }
public string NewSource { get; set; }
public string Author { get; set; }
public string AuditDate { get; set; }
public string Hits { get; set; }
public string Content { get; set; }
}
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MeteDate entity=new MeteDate();
entity.Title = "测试";
entity.NewSource = "工会";
entity.Author = "Gavin";
entity.AuditDate = "2013-12-04";
entity.Hits = "23";
entity.Content =GetContent();
List<MeteDate> dt=new List<MeteDate>();
dt.Add(entity);
RptNews.DataSource = dt;
RptNews.DataBind();
}
public string GetContent()
{
string result = "";
for (int i = 0; i <= 200; i++)
{
result += "<p style='font-size: 16px;'>" + i + "第六十六条 国家通过各种途径,采取各种措施,发展职业培训事业,开发劳动者的职业技能,提高劳动者的素质,增强劳动者的就业能力和工作能力。" +
" 第六十七条 各级人民政府应当把发展职业培训纳入社会经济发展的规划,鼓励和支持有条件的企业、事业组织、社会团体和个人进行各种形式的职业培训。"+
"第六十八条 用人单位应当建立职业培训制度,按照国家规定提取和使用职业培训经费,根据本单位实际,有计划地对劳动者进行职业培训。"+
" 从事技术工种的劳动者,上岗前必须经过培训。" +
" 第六十九条 国家确定职业分类,对规定的职业制定职业技能标准,实行职业资格证书制度,由经过政府批准的考核鉴定机构负责对劳动者实施职业技能考核鉴定。</P>";
}
return result;
}
}
}
The code in Test.aspx.cs is simple, and I find that once the string contains lots of chinese character ,then there may be chinese character replaced by "??".I will also show the config for my project ,even I think there is not so necessary.the web.config for my project is:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
</authentication>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
<httpHandlers>
<add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false" />
</httpHandlers>
<httpModules>
<add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
</httpModules>
<pages>
<controls>
<add assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" />
</controls>
<namespaces>
<add namespace="Ext.Net" />
<!--<add namespace="Ext.Net.MVC"/>-->
</namespaces>
</pages>
<httpRuntime requestValidationMode="2.0" executionTimeout="3000" maxQueryStringLength="409600" maxRequestLength="40960" />
<globalization fileEncoding="utf-8" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="DirectRequestModule" preCondition="managedHandler" type="Ext.Net.DirectRequestModule, Ext.Net" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="DirectRequestHandler" verb="*" path="*/ext.axd" preCondition="integratedMode" type="Ext.Net.ResourceHandler" />
</handlers>
<defaultDocument enabled="true">
<files>
<clear />
<add value="default.aspx" />
</files>
</defaultDocument>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<extnet theme="Gray" />
</configuration>
So I wonder maybe there is some bug in Ext.net dealing with our chinese charactor.This reminds me of another interesting thing.Ok look the two java method following used to transform "InputStream" to "string".look the follow picture.The left one I read inputStream by "new Byte[4096]",in this condition the result is that maybe a chinese character can be split to two character that can not recognized ,just like "??".And the right one works properly.
So I think there maybe a bug dealing with chinese character in Ext.net. When Ext.net dealing with the stream or a long string ,Ext.net maybe split a chinese character to two parts. For example ,"社" is "c9e7" in GBK Encoding,maybe we split it to "C9"and "E7" ,and then there is "??".
I am confused and this makes bad influence for my project.Please help me.
I will be very glad to receive your reply and expect you can help me solve this problem,thanks.
My Email is lushicheng@live.cn
Last edited by geoffrey.mcgill; Dec 18, 2013 at 3:17 AM.